Important Linux Commands
The Linux commands covered in this section will give you some essential tools to manage your Linux environment. You'll also be able to use these commands on other Unix-based systems. You'll pick up other important commands in the "Text Editors" and "Slicing and Dicing" sections but you should first master this starter set to build the skills that will help you perform common Linux tasks more easily.
Use the date command to print the current date and time. If you add the -u flag, the results will be for the Greenwich mean time zone. And if you log in as a superuser, you can even change the date or time with the -s flag. Now, that's power!
Here are some examples:
Date and Time
date Print the date and time.
Sat Nov 2 20:09:43 EST 1996
date -u Print the GMT date and time.
Sun Nov 3 01:09:45 GMT 1996
date -s 0503 Set the clock to 5:03 A.M.
echo
The echo command displays a message on the screen and is primarily useful for programmers writing shell scripts. But anyone can use echo to show the value of environment variables. The echo command displays a message on the screen and is primarily useful for programmers writing shell scripts. But anyone can use echo to show the value of environment variables. Here are some examples:
echo $PATH
/usr/bin:/usr/local/bin
echo My name is $USER - Home directory=$HOME.
My name is hermie - Home directory=/home/hermie.
Spell Check
spell important.txt Perform a regular spell check on important.text.
spell -b important.txt Perform a spell check using British spelling rules.
ZIP and UnZIP
zip squash.zip file1 file2 file3
Then you can extract the original files like this:
unzip squash.zip
If You Need Help, Ask the man
Assuming you can remember the right command for a particular job, it's tougher still to remember all the switches associated with that command. The man command (short for manual) will help you on both counts by displaying pages from online manuals and telling you which commands may be relevant to the task at hand. Say you want to change your password, but you don't know the command to do it. You can use the man command plus the keyword flag, -k, to search by keyword password for relevant commands:
man -k password
passwd passwd (1) - change login password
pwck pwck (1m) - password/group file checkers
vipw vipw (1b) - edit the password file
You can probably deduce that passwd is the correct command. But before blindly issuing any Linux command, you should know the proper syntax and understand what the command might do to you first. Using man with a command name will display all you need to know (probably more) about a command. For example, entering
man passwd ..will display
passwd(1) User Commands passwd(1)
NAME
passwd - change login password and attributes
SYNOPSIS
passwd [ name ]
passwd [ -d | -l ] [ -f ] [ -n min ] [ -w warn ]
[ -x max ] name
passwd -s [ -a ]
passwd -s [ name ]
DESCRIPTION
The passwd command changes the password or lists
attributes associated with the user's login name.
--More--(5%)
The man command pauses after each screenful and waits for you to press the spacebar before continuing. The word 'More' at the bottom of each page indicates how much of the help has so far been displayed. The terms in square brackets are optional parameters (-d, -l, -f, for example); vertical bars indicate that the terms on either side are mutually exclusive (you can use only one at a time)
man command help
man - format and display the on-line manual pages
manpath - determine user's search path for man pages
|