infuerno.github.io

Shotts, The Linux Command Line, No Starch Press

Learning the Shell

User prompt ends with $, super user prompt ends with #

Common ls Options

Option Long Option Description
-a –all all files, including hidden
-d –directory with -l show details about the directory rather than its contents
-F –classify append an indicator character to end of each item (e.g. forward slash if name is a directory).
-h –human-readable with -l display file sizes in human-readable format rather than in bytes
-l long format
-r –reverse display results in reverse order
-S sort results by file size
-t sort by modification time

Fields in long listing

-rw-r–r-- 1 root root 453764 2012-04-03 11:05 oo-welcome.odt

1 = File’s number of hard links (often 1) root = user who owns the file root = group who owns the file 453764 = size in bytes 2012-04-03 11:05 = last modified date

Directories Found on Linux Systems

Directory Comments
/ root directory
/bin binaries for the system to boot and run
/boot Linux kernel (/boot/vmlinuz), initial RAM disk image (drivers needed at boot time), boot loader
/dev list of all devices
/etc system wide config files, shell scripts for starting system files
/lib shared library files for core system programs
/lost+found used in partial recovery situations, usually empty
/media mount point for CD drives etc
/mnt older systems manual mount point for removable drives
/opt optional software
/proc virtual file system maintained by the kernel - not a real files system - but all files are readable
/root home directory for the root account
/sbin system binaries
/tmp temporary files
/usr all programs and support files used by regular users
/usr/bin binaries installed by the linux distro - usually 1000s of programs
/usr/lib shared libraries for /usr/bin
/usr/local system wide, but usually not via the linux distro, but via a sys admin user e.g. /usr/local/bin is where programs compiled from source usually go
/usr/sbin more system binaries (TODO what is the difference between here and /sbin?)
/usr/share shared data for programs in /usr/bin e.g. default config files, icons
/usr/share/doc documentatino
/var storage for data which is likely to change e.g. logs, databases, email
/var/log log files - /var/log/messages is important

Wildcards

Manipulating files

cp

mv

rf

Commands

A command is one of:

I/O Redirection

stdout, stderr and stdin can be thought of as files where the output for stdout and stderr is by default connected to the screen and the input for stdin is, by default, connected to the keyboard. These can be redirected using I/O redirection.

Configuration and the Environment

A Gentle Introduction to VI