• Happy holidays, folks! Thanks to each and every one of you for being part of the Tom's Hardware community!

linux operating system

Unix shell script.

Most Linux distributions use Bash as their main shell, which is backward-compatible with (and extends) the traditional Bourne shell. It's very powerful and, like the Windows command shell, you can both type commands directly and write scripts.

To get the built-in commands, the Bash manual (either on the Web or by typing "man bash") is the definitive reference.

Look for Linux shell or command line tutorials if you need to learn how to use it.

A few quick starters:

  • ■ ls - list the files in the current directory (folder)
    ■ ls /bin - lists the files in the /bin directory
    ■ ls -l - a more detailed (-l = "long") listing
    ■ cd Downloads - change to the directory called "Downloads" - note that Unix OSes are case-sensitive so "Downloads" and "downloads" are different and both can exist at the same time
    ■ cat readme.txt - dump the file called "readme.txt" to the screen
    ■ less readme.txt - view the same file in a more friendly way - up/down arrows or PgUp/PgDn to navigate, Q to quit
    ■ rm uselessfile.txt - delete (remove) a file
    ■ rm -r directoryname - remove a directory recursively - it will probably not ask for confirmation
    ■ df - show free space on mounted drives
    ■ lspci - list all the PCI devices in the system (may need to be run as "sudo lspci" which makes it run as an admin)
For almost any command, you can add the --help option (e.g. "ls --help") and it will give a more or less terse list of options. There is also likely to be a man-page which may give you more detail (e.g. "man ls"). Most programs live in the /bin and /usr/bin directories (system admin commands may be in /sbin or /usr/sbin).

You can usually scroll back a certain way through the output with Shift-PgUp (if you're in text-only mode; otherwise just use the scroll bar on the terminal window). You can "pipe" output from commands into "less" to allow you to browse it more easily by doing, for example, "ls -l /usr/bin | less". If you're geeky like me, you may find "dmesg | less" interesting - dmesg dumps the kernel message buffer which shows all your hardware being probed and initialised during the boot process, along with any other kernel messages.

You can also "tab-complete" both commands and filenames: typing "ls /u" then pressing Tab will probably auto-complete "ls /usr/". If there's more than one possible completion (for example, "ls /b"[Tab] could be either /bin or /boot), pressing Tab a second time will list the possible options; typing another letter and pressing Tab again should work.