Linux Mint: From scratch - part VI
The Command Line (continued)What you interact with in a Linux terminal window is called a shell -- a piece of software that provides access to the operating system's kernel. All you really need to know about it is that all Linuxes (and Mac OS X for that matter) use a shell called Bash -- short for the Bourne-again Shell, a development of one of the original Unix shells called, not surprisingly, the Bourne Shell.
Below is a collection of tips and tricks you might find useful for finding your way around Bash.
Detailed information
You can always find detailed information about a shell command by prefixing it with man (short for "manual"). So man ls for example will tell you all you need to know about the ls command.

Navigate through man with the <Page Up>, <Page Down> and arrow keys. Press Q to quit.
Directory and file stuff
As you'll see above, the ls command lists a directory's contents. At its most basic it does so on a single line:

but adding an optional argument -- this case ls -l -- provides more detailed output:

Any file prefixed with a dot (.) in Linux is considered "hidden". That doesn't mean they're super-secret or anything like that. It's simply an indication that they're system files not usually of interest to the average user.
You can see all hidden files by adding the -a parameter:

Parameters can be combined. For example ls -la yields (in part):

Linux defaults to displaying file sizes in blocks, so one very useful parameter that works on many file-related commands is -h. It converts blocks in human-readable format -- eg. 1K, 234M, 5G, etc.
Try comparing the output of df ("show disk usage") and df -h and you'll see the difference:



Whoa, hold on a sec. Did you just get a concise display of the size, use and free space available on all the disks available to your machine -- including those on the network -- from a simple two-letter command? Yep. That's the power of the Linux command line!
Here are a few more commands to try:
| cat |
Concatenate and display the contents of file(s). |
| cd |
Change directory. (cd
on its own will always take you back to your /home directory.) |
| cp |
Copy one of more files. |
| du |
Show disk usage. |
| file |
Determine a file's type. |
| grep |
Search file(s) for lines
containing a match to a given pattern. |
| head |
Display the first part of a file. |
| history |
Show command history |
| ifconfig |
Display (and optionally
configure) network interfaces. |
| locate |
Find files. |
| lsof |
List all output files. |
| lsusb |
List all USB devices. |
| mkdir |
Make a directory. |
| more |
Display output one screen at
time. |
| ps |
Show process status. (Eg: ps -e) |
| pwd |
Print working (current)
directory. |
| rename |
Rename file(s). |
| rm |
Remove file(s). |
| rmdir |
Remove directory. |
| tail |
Output the last part of a file. |
| top |
List all processes running on
the system. (Press Q to quit.) |
| whomai |
You mean you really don't know?
;-) |
You'll find a much more comprehensive list here.
Quick links to previous parts:
Part I, Part II, Part III, Part IV, Part V

PC World is New Zealand’s top selling computing and technology magazine.
Comments
You might want to check the spelling of that last command. whomai.
Posted by: Craig | August 25, 2012 10:25 PM
One really cool function of 'man' is that you can also print the pages too. The command to print the man pages for the 'ls' command is:
man -t ls |lp
You get nice formatted output that can go into a printed manual.
Posted by: Adrian Williams | August 20, 2012 2:43 PM