Newbie Command Line Essentials

From Sfvlug

If you don't know your commandline very well you should, at the least, know enough about some basic tools that you have at your disposal to do some basic tasks and find the necessary additional information you may need. This section will contain only the basics to enable you to get done what you need to do at the command line.

Search and documentation tools are some of the most important tools you can learn. They can help you get past some hurdles you may encounter. Here is a brief list of a few of the most popular, all of which can be accessed through your command line terminal (xterm, rxvt, etc...) or console. You can access a terminal from your desktop menu where specific instructions vary with different desktop environments such as Gnome, KDE, Xfce or any number of those less known. You can access a console by entering (<ctrl><alt>Fn) Where 'Fn' is a function key from F1 through F6. Note: These commands are in no particular order and some examples may not be applicable in all distributions or setups.

The king of all the command line commands is 'man' because with it you can access information on just about all standard commands as well as many configuration files and other miscellany. It provides you with the manual often referred to in 'RTFM' and should be the first place to look for answers. You may not find the all the information you need in a feature's man page, but if it is there and you have gone straight to a knowledgeable human instead, you may not get the pleasant and informative response you would like. The standard procedure for finding needed information should be to first check local documentation already on your computer or if you have one in a reference book or manual made from dead trees. Failing to find local information, the next step is to do a search on the Internet using Google or your own favorite search engine. If you still don't have an answer go and read How To Ask Questions The Smart Way by Eric Raymond before asking a stranger. Not every answer can be found by "RTFM" but when someone responds "RTFM" you can answer that you already have along with the reason why you were unable to find what you needed.


Info

man - an interface to the on-line reference manuals (ex: man hier)
find - search the manual page names and descriptions (ex: find ~ -name '*.mp3')
locate - security Enhanced version of the GNU Locate (ex: locate hosts)
updatedb - update the slocate database (ex: updatedb&)
which - locate a command (ex: which ifconfig)
whereis - locate the binary, source, and manual page files for a command (ex. whereis ifconfig)
hier - description of the file system hierarchy (ex. man hier)
apropos - search the manual page names and descriptions (ex. apropos <keyword>)
less - page through text one screenful at a time allowing for forward and backward movement in the file (ex. less
/usr/share/doc/debian/debian-manifesto)
su - change user ID or become super-user (ex. su - <passwd>)
sudo - execute a command as another user (ex. sudo /etc/init.d/networking)
history - display the list of commands previously typed (ex. history)

Keystrokes

<ctrl>r - reverse keyword search of the command history (ex. <ctrl>r<keyword>
/ - search forward for occurance of keyword in a manpage, many editors and pagers (ex. /<keyword>)
? - search backward for occurance of keyword in a manpage, many editors and pagers (ex. ?<keyword>)
n - continue to the next occurance of the keyword searches listed above (ex. n)

Network

ifconfig - configure a network interface (ex. ifconfig eth0 192.168.0.2)
route - show / manipulate the IP routing table (ex. route add -net default gw 192.168.0.1)
iwconfig - configure a wireless network interface (ex. iwconfig eth2 essid GaylesPerk channel 11 mode auto)
iwlist - get more detailed wireless information from a wireless interface (ex. iwlist eth2 scan)
ifup - bring a network interface up (ex. ifup eth0)
ifdown - take a network interface down (ex. ifdown eth0)

Paths

/usr/share/doc, /usr/local/doc - documentation paths
/var/log - path of all your log files
/etc - most of your config files
/etc/init.d - system service control scripts
~ - an abbreviation of your home directory (long form: /home/user)
/ - root path, the base/parent path of all paths
. - current working directory
./ - path based off of the current working directory
../ - parent path 

Special Characters

Note: not all essential but all worth learning early
| - pipeline command, the standard output of one command is connected to the standard input of another command
    (ie take the output of one  command and send it to another)
\\ - preserves the literal value of the command that follows, except newline
    (takes any special characters and turns them into something akin to text characters)
& - if a command is terminated by the control operator &, the shell executes the command in the background in a subshell 
&& and || - the control operators && and ││ denote AND lists and OR lists, respectively. An AND list has the form:
    command1 && command2 (Note: command2  is  executed if, and only if, command1 returns an exit status of zero)
; - commands separated by a ; are executed sequentially

Useful Info (Optional but worth learning as you go!)

Note: These your should pursue in your own time using the commands listed above for additional information!

General: alias, free, jobs, fg, dmesg, uname, xargs
Pattern Matching: grep, rgrep, egrep, fgrep
Process: top, ps, pgrep, nice, renice, kill, pkill, killall
Network: route, traceroute, arp, netstat, ping
File and Filesystem: cp, mv, rm, ls, cd, chmod, chown, cat, du, df, lsof, touch
Conveniences: ssh-agent, keychains, screen
Debian Package Manager: apt-get, dpkg, apt-cache, apt-file (Note: Debian based distribution specific)
Files and File Locations: /etc/passwd, /etc/hosts, /etc/hosts.allow, /etc/hosts.deny, /etc/hostname, /etc/resolv.conf, /etc/groups,
                          /etc/fstab, /etc/modules, ~/.bashrc, ~/.bash_profile, ~/.bash_aliases
Your Ad Here
Personal tools
Other sites