Linux Commands Explained
There are many different commands you can enter to configure and interact
with linux.
These commands can be entered at the shell prompt, or command (line) prompt.
If you use linux with a GUI, look for the shell program icon. If you have
no GUI installed you should be looking at the prompt, and if you log in
remotely you will be at the prompt.
There are two types of commands, shell commands and linux commands.
Shell Commands
Shell commands are part of the shell program. There are several different shells (C shell, bash shell, bourne shell etc) to choose from, and each will have a variation of the shell commands built in. The commands vary between shells, but each shell is the same across different linux distros.
Linux Commands
Linux commands are not part of the shell. Each one is a seperate executable
program, probably written in the C programming language.
These executables are stored in various directories set up for binary
files, such as /bin and /usr/bin. The location of these directories can
be defined with the $PATH variable so the shells know where to find them.
These commands vary between different linux distrubutions, and remain
the same whichever shell you are using.
The Command Prompt
What your prompt looks like will depend on the shell you use (bash, borne,
csh etc), and the settings you have for that shell.
I use a bash shell, and have the prompt set up to look like this......
This shows me I am logged in as root, to the computer called cirrus,
and I am in a folder called home.
TIP: To see the full path of the folder 'home', use the pwd
command.
Your prompt is bound to look different, so for the purpose of this section I will just use the > to represent the prompt.
Linux Commands
Some linux commands are very simple and need nothing more than the command itself.
For example the command ls (list) will simply list the names of the directories and files in the current directory...
files/
images/
index.txt
>
In this instance ls shows there are two directories, called files and images, and a text file called index.
However you can often add options or parameters, which are usually added to the command after a '-'.
Adding the option -l will give you a long listing which includes the permissions, ownership, size, date/time, and name of the files and directories...
drwx------ 2 bob bob 4096 Aug 22 10:31 files/
drwx------ 3 bob bob 4096 Mar 19 11:17 images/
-rwx------ 1 bob bob 284 Mar 18 10:23 index.txt
>
.hiddenfile
files/
images/
index.txt
>
This shows there is a hidden file (hidden files have a '.' before the filename) called '.hiddenfile', as well as the two directories and index file.
You can use more that one option at a time...
>ls -la would produce a long listing format of ALL (including hidden) directories and files in the current working directory.
There are many options for some linux commands, and the best place to find out about then all is the 'man' pages. These man pages show you how to format the command, and what options and parameters there are to use with each command.
Below is a list of commonly used commands with explanations aimed at Linux command prompt beginners.
Command |
Description |
cd | Change directory |
locate | Find files |
ls | List information about file(s) |
pwd | Print Working Directory |