Upgrade to Pro — share decks privately, control downloads, hide ads and more …

A quick Linux 103 - post installation tasks, the Command Line Interface (CLI) and proper package management under Linux

A quick Linux 103 - post installation tasks, the Command Line Interface (CLI) and proper package management under Linux

A quick Linux 103 - post installation tasks, the Command Line Interface (CLI) and proper package management under Linux by Brian Byrne

Bar Camp, London. 11th May version.

Brian Linuxing

May 11, 2019
Tweet

More Decks by Brian Linuxing

Other Decks in Technology

Transcript

  1. A quick Linux 103 - post installation tasks, the Command

    Line Interface (CLI) and proper package management under Linux by Brian Byrne May 2019, Bar Camp, London. Revised: May 2019, 0.2 (new numbering scheme) Linux 103 by Brian Byrne. Twitter:@BrianLinuxing Email: [email protected]
  2. Brian Byrne is a freelance IT manager, a thinker and

    do-er for hire. He started coding around 1971, over time he has written programs in 14+ languages, although Turbo Pascal remains one of his favourites. Brian organises Linuxing In London, co-organises Community, Covent Garden Pi Jam and all London Raspberry Pi Jam (mini-science festivals for kids), plus a lot more. He likes tea, good manners and speaking poor Spanish. He prefers community management to being a boring IT Manager and is a bit of a know-all! NB: Brian speaks in paragraphs. Linux 103 by Brian Byrne. Twitter:@BrianLinuxing Email: [email protected]
  3. What’s an IT Manager? Generally, the ultimate geek! Lives, breathes,

    smells and loves technology. Linux 103 by Brian Byrne. Twitter:@BrianLinuxing Email: [email protected] 1,400 pages of operating system joy.
  4. Congratulate yourself! By this stage you have completed either the

    Linux 101 or Linux 102 You have a working Linux system. Now we have to learn how to manage it. Linux 103 by Brian Byrne. Twitter:@BrianLinuxing Email: [email protected]
  5. Brief agenda: Post installation, what must be done, what should

    be done and what could be done. How to operate a Linux system, what to do and what to avoid, covering the Linux command-line extensively. Linux 103 by Brian Byrne. Twitter:@BrianLinuxing Email: [email protected]
  6. What this class is not: An MSc in computer science.

    The last word on everything about Linux. But, it will provide: A basic Linux 103, a hands-on approach to managing a Linux system and many of the gotchas! It will be the start of your journey to learnt about Linux. Linux 103 by Brian Byrne. Twitter:@BrianLinuxing Email: [email protected]
  7. What we will do: Perform post-installation tasks. Optional customisation and

    nice to have. Learn about command line software installation. The power of the command line interface (CLI), basic commands, key files, performance tuning, etc., Finally, you will be master of your own Linux system. NB: These commands should apply on almost any Debian or Ubuntu derived system: AWS, GCP, etc., but read the manual first. Linux 103 by Brian Byrne. Twitter:@BrianLinuxing Email: [email protected]
  8. Prerequisites 1. A working Linux system based on Debian/Ubuntu or

    similar. 2. Pen and paper. 3. Bags of concentration. Linux 103 by Brian Byrne. Twitter:@BrianLinuxing Email: [email protected]
  9. A word of warning: Linux is not Windows, don’t treat

    it as if it were. Linux 103 by Brian Byrne. Twitter:@BrianLinuxing Email: [email protected]
  10. Technical demo (switch to Linux laptop) [NB: all Linux commands

    should be in lowercase, Linux is case sensitive] Linux 103 by Brian Byrne. Twitter:@BrianLinuxing Email: [email protected]
  11. 1. Perform post-installation tasks. Update the software and install more

    applications. [NB: all Linux commands should be in lowercase, Linux is case sensitive] See point 3. Linux 103 by Brian Byrne. Twitter:@BrianLinuxing Email: [email protected]
  12. 2. Gotchas, security and what not to do. A word

    about normal users and root access. Generally, users cannot break a Linux system but root (or superuser) can. sudo <command> sudo -i for a longer session but take extra care. Gotchas: Don’t CTRL-C system updates/upgrades, etc., or you’ll end up with a broken package management system, and your Linux system will, in the end, become broken. Treat Linux with respect or it will bite you back. Linux 103 by Brian Byrne. Twitter:@BrianLinuxing Email: [email protected]
  13. 3. Perform a complete system upgrade (think Google Store or

    App Store) sudo -i apt-get update && apt-get -V dist-upgrade [Watch the output very carefully, do it at home, can take 20-30+ minutes, by your router.] NB: Take a break, but remember don't interrupt apt-get or it might break your Linux system. Linux 103 by Brian Byrne. Twitter:@BrianLinuxing Email: [email protected]
  14. 3.1 A word on dependency management and libraries. Only install

    packages via the build-in package manager, apt-get, dpkg or synaptic, etc., Do it any other way and you risk busting your package management system and your whole Linux set-up! And if you do it could mean another reinstall from scratch. Be extra careful. Linux 103 by Brian Byrne. Twitter:@BrianLinuxing Email: [email protected]
  15. 4. The order of proper system management 1. Install the

    operating system. 2. Reboot. 3. Do an update/upgrade. 4. Reboot. 5. Add any additional accounts. 6. Add any other apps, as required. 7. Check log files and performance. Linux 103 by Brian Byrne. Twitter:@BrianLinuxing Email: [email protected]
  16. 5. Change defaults and create your own user account 5.1

    Type, passwd Pick a new password for the default Linux account. 5.2 sudo -i passwd root Linux 103 by Brian Byrne. Twitter:@BrianLinuxing Email: [email protected]
  17. 5.3 Type, adduser <your new username> [Fill in] 5.4 Add

    to sudo group usermod -aG <your new username> sudo Verify new user account has access to sudo, by logging out and logging in again, then type sudo -i from your new account. If in doubt check /etc/sudoers Linux 103 by Brian Byrne. Twitter:@BrianLinuxing Email: [email protected]
  18. 6.2 Finding apps/packages with the command line apt-cache search chess

    >file more file grep <text to search for> file A typical Linux repository (where packages are kept for later installation) for Peppermint Linux 8 has over 58,000 packages listed. 58,000+. A working system probably has >3000+ packages installed. Linux 103 by Brian Byrne. Twitter:@BrianLinuxing Email: [email protected]
  19. 6.3 apt-get - is a frontend apt-get is a frontend

    to dpkg and ALWAYS the best way, but dpkg -l (L) is useful. A partial sample listing is shown below. Desired=Unknown/Install/Remove/Purge/Hold | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad) ||/ Name Version +++-===========================================================-========================= ii abiword 3.0.1-6ubuntu0.16.04.1 ii abiword-common 3.0.1-6ubuntu0.16.04.1 ii abiword-plugin-grammar 3.0.1-6ubuntu0.16.04.1 ii accountsservice 0.6.40-2ubuntu11.3 ii acl 2.2.52-3 ii acpid 1:2.0.26-1ubuntu2 ii adduser 3.113+nmu3ubuntu4 ... Linux 103 by Brian Byrne. Twitter:@BrianLinuxing Email: [email protected]
  20. 6. More basics software installation with apt-get 6.1 Installing with

    the command line apt-get update – are we online? Give me an up to date feel for all of the packages. apt-get –V install <package> E.g. apt-get install –y –V glances Linux 103 by Brian Byrne. Twitter:@BrianLinuxing Email: [email protected]
  21. 7. The command line and the shell (bash) There are

    various shells on Linux (the Bourne shell was created Steven Bourne and default on V7 Unix). Bash - Bourne Again Shell Ksh - Korn shell Fish - friendly interactive shell zsh - extended Bourne shell csh - C shell dash - Debian Almquist shell Linux 103 by Brian Byrne. Twitter:@BrianLinuxing Email: [email protected]
  22. 7.1 What’s the shell? In UNIX, Linux, BSD (Berkeley Standard

    distribution) and even OpenVMS (a mainframe operating system), the shell is the program which interprets what you typed on the command line. It then actions it accordingly. That could mean showing you the directory, or bringing up an application, it depends on what you type It offers the flexibility to run scripts (as with Python or similar languages) and it is your main interface to the operating system. Linux 103 by Brian Byrne. Twitter:@BrianLinuxing Email: [email protected]
  23. 7.2 What am I running? cat /etc/shells echo $SHELL The

    default in this instance is bash. 7.3 Recall buffer and CTRL-R <CTRL-R> <A letter or 2> Linux 103 by Brian Byrne. Twitter:@BrianLinuxing Email: [email protected]
  24. 7.4 The history command Writing the history buffer to a

    file history –w whatihavejustdone.txt Clear the history history –c Linux 103 by Brian Byrne. Twitter:@BrianLinuxing Email: [email protected]
  25. 8. Some basic Linux commands for file management, etc., (think

    MS-DOS) ls – list files, e.g. ls -alh mkdir – make a directory cd - change to a directory pwd - where am I cd $HOME – take me to the top level directory more – type something to the console mv – really renames files but moves them too (NB: use with care) ... Linux 103 by Brian Byrne. Twitter:@BrianLinuxing Email: [email protected]
  26. cp – copy files tail – the bottom of a

    file, eg. tail <filename> or tail -n 200 <filename> nano – a simple editor rm – erases files, be careful, particularly when in root. rmdir – removed an empty directory diff – compare two files, eg. diff –y –w132 <file1> <file> Linux has a wide range of GUI (graphical user interface) programs too! Linux 103 by Brian Byrne. Twitter:@BrianLinuxing Email: [email protected]
  27. 9. Key files and how not to break Linux 9.1

    Directories Don’t touch anything in /etc unless you have to. Don’t delete anything from /usr/bin or /usr/sbin/ 9.2 Making space If you need to remove a package use apt-get purge <package> Linux 103 by Brian Byrne. Twitter:@BrianLinuxing Email: [email protected]
  28. 9.3 Where to look ls –rtcl /var/log is handy tail

    /var/log/syslog [On systemd? use journalctl] dmesg – watch like a hawk, use -T to make sense of time df -h is useful for overall disk space Linux 103 by Brian Byrne. Twitter:@BrianLinuxing Email: [email protected]
  29. 10. Performance monitoring with top and free Tuning systems is

    very, very involved and an almost full time job. top – watch Tasks (top left) and free memory, q quits, h for help free – shows free memory, more readable with free –m df - look at your devices, e.g. df -hT When Linux runs out of memory it will start killing processes, beware Linux 103 by Brian Byrne. Twitter:@BrianLinuxing Email: [email protected]
  30. 10.1 glances If in doubt, use glances, it is very

    good. install via apt-get update && apt-get install -V glances 10.2 process status ps -e or ps -ef or ps -e --forest Linux 103 by Brian Byrne. Twitter:@BrianLinuxing Email: [email protected]
  31. 11. Shutting down, doing it properly sudo shutdown –h 5

    - halts the system sudo shutdown –r 2 - reboots the system sudo shutdown –c - cancel the shutdown Use these instead of the halt and reboot commands. Don’t just unplug the power, or you will eventually break your Linux system. Linux 103 by Brian Byrne. Twitter:@BrianLinuxing Email: [email protected]
  32. 12. Clever things with Linux, using the GUI remotely X

    clients and X servers (1984 - MIT, now seen as X11 - version 11) ssh to the server with the -XC options from Linux then invoke synaptic or Firefox. Windows systems need to have an X client running (Xming or Cygwin). Macs might need security options fixing, for more modern systems see XQuartz project. The process load is on the Linux system, not the client or your PC/laptop, etc., Linux 103 by Brian Byrne. Twitter:@BrianLinuxing Email: [email protected]
  33. 13. Lost your Linux system? Do this only on your

    home network, not anywhere else. 13.1 Install zenmap and nmap apt-get update && apt-get –y –V install zenmap Linux 103 by Brian Byrne. Twitter:@BrianLinuxing Email: [email protected]
  34. 13.2 Scan the whole network (everything) from the CLI nmap

    –sP <IP range/24) e.g. nmap -sP 192.168.1.0/24 or nmap -sn 192.168.1.* or nmap -sP 192.168.1.1-255 13.3 Who am I? Find your own IP address by typing, ifconfig Linux 103 by Brian Byrne. Twitter:@BrianLinuxing Email: [email protected]
  35. 15. Summary of proper system management 1. Install the operating

    system. 2. Reboot. 3. Do an update/upgrade. 4. Reboot 5. Add any additional accounts. 6. Add any other apps, as required. 7. Check log files and performance NB: Use apt-get, etc to install programs and apps, any other way might break your system. Linux 103 by Brian Byrne. Twitter:@BrianLinuxing Email: [email protected]
  36. Fini For additional material and answers see the FAQs Linux

    103 by Brian Byrne. Twitter:@BrianLinuxing Email: [email protected]
  37. Frequently asked questions (FAQs): Q: Where are the slides kept?

    A: These are just draft ones, but the final version will always be at speakerdeck as BrianLinuxing. https://speakerdeck.com/brianlinuxing Linux 103 by Brian Byrne. Twitter:@BrianLinuxing Email: [email protected]
  38. Q: Why use the command line interface (CLI) when the

    Graphical user interface (GUI) is easier. A: The command line interface is used extensively in cloud computing, it is a desirable skill to have, not obvious and a little tricky at times but once it’s been explained it becomes incredibly powerful. The GUI is a simple interface not dissimilar to Windows, and fairly intuitive, it really doesn’t need much explaining, if at all. The CLI is what people really want to learn and ask about! Linux 103 by Brian Byrne. Twitter:@BrianLinuxing Email: [email protected]
  39. Q: How does TCP/IP work? A: TCP/IP is an immensely

    complex network protocol, but from our point of view we just need to know if you plug in a device it will request a TCP/IP address. That address is supplied by a DHCP server. In most instances that will be your home or office router. Q: What does DHCP mean? A: Dynamic Host Configuration Protocol Linux 103 by Brian Byrne. Twitter:@BrianLinuxing Email: [email protected]
  40. Q: Where can I learn more? Google is a good

    starting place, but many of the articles on the web are over-elaborate for beginners. The forums can be useful at times. Q: Isn't Linux too complicated to learn? Learning Linux is no more complicated than becoming familiar with another language or mastering the art of car driving. It takes patience, a degree of persistence but the rewards are immense. Linux 103 by Brian Byrne. Twitter:@BrianLinuxing Email: [email protected]
  41. Q: What should I do now? Spent time reading, tinkering

    and if you ruin the Linux's file structure then you can always recreate it using the instructions in Linux 101 or 102. Q: My commands never work under Linux on the command line. A: Linux is case sensitive, take extra care. Linux 103 by Brian Byrne. Twitter:@BrianLinuxing Email: [email protected]
  42. Q: What does && and all of those funny Linux

    symbols do? A: They are called chaining operators, see https://www.tecmint.com/chaining-operators-in-linux-with-practical-examples/ Q: What else? Twitter is very useful, I am on there as @BrianLinuxing ! Linux 103 by Brian Byrne. Twitter:@BrianLinuxing Email: [email protected]
  43. Q: I need help, what do I do? A: Type,

    man <linux command> as a starter or typically <linux command> --help Q: You didn’t answer my question. A: Linux is a complex operating system and can’t be rushed! Self study is always useful :) Linux 103 by Brian Byrne. Twitter:@BrianLinuxing Email: [email protected]
  44. Q: I have many, many more questions where should I

    go? A: Let Google be your friend in this case :) Linux 103 by Brian Byrne. Twitter:@BrianLinuxing Email: [email protected]
  45. The End Thank you for participating and if you enjoyed

    the event, slides, etc. then please leave a nice comment on Twitter or MeetUp. Linux 103 by Brian Byrne. Twitter:@BrianLinuxing Email: [email protected]