guest@linuxthings:~/guides$ man intro
Introduction
Welcome to the linuxthings interactive reference. This guide helps you work productively with the Linux operating system, focusing on the bash shell command-line interface.
The Shell
The shell is a program that accepts commands from the keyboard and executes them. It is your primary interface to the system. A typical command consists of a program name followed by options (usually starting with -) and arguments.
command [options] arguments
wc -l myfileIn the example above, 'wc' is the program (word count), '-l' is an option (lines), and 'myfile' is the argument (the file to process).
Options and Arguments
Options are not standardised across programs. Most take a single dash and one letter (-l), many also accept a long form with two dashes (--lines), and the same letter can mean different things to different commands: -l means "lines" to wc but "long listing" to ls.
wc -l -w myfile # Two separate options
wc -lw myfile # Same thing, options combined
wc --lines myfile # Long-form option
wc -l file1 file2 # Several arguments at once
who | wc -l # Pipe one command's output into anotherUsers and the Superuser
Linux is multi-user. Ordinary accounts can only change their own files, while the special root account (the superuser) can do anything. Prefix a command with sudo to run just that command with root privileges.
whoami # Which user am I?
wc -l /etc/shadow # Fails: Permission denied
sudo wc -l /etc/shadow # Works after you enter your passwordsudo can damage your system as easily as it can fix it. Read a command twice before running it with sudo.
Getting Help
man ls # Read the manual page for ls (q to quit)
man -k partition # Search manual pages by keyword
info coreutils # Hypertext documentation for GNU tools
ls --help # Short built-in usage summary
type cd # Is it a program, a builtin or an alias?
ls /usr/share/doc # Extra documentation shipped with packagesInside man and info, press / to search, n for the next match and q to quit. Your distribution's own documentation and the Arch Linux wiki are also excellent references, whatever distro you run.