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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
>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]
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]
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]
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]
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]
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]
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]
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]
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]
/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]
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]
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]
- 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]
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]
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]
–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]
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]
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]
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]
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]
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]
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]
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]
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]
the event, slides, etc. then please leave a nice comment on Twitter or MeetUp. Linux 103 by Brian Byrne. Twitter:@BrianLinuxing Email: [email protected]