I don’t know any commands

The Whole Linux Command Thing: Why Have Commands?

Just as cavemen learned to develop their skills from grunting and groaning to writing meaningful representations on the walls of caves, The computer world started off with the keyboard and the CLI (Command Line Interface). All action that happened on any system would be inherently text. Xerox’s PARC research center managed to invent the very first graphical user interface. When Linux first came to be in 1991, most things were still text. True, Windows 3.0 was out, and MacOS had been with us since 1984 but the PC world was still dominated with text. MS-DOS still ran the PC show. Anyone who wanted to use their PC efficiently back in 1991 with a Microsoft machine, would use Windows to run their graphical programs like Aldus PageMaker and Lotus 1-2-3, but they would open an MS-DOS prompt box, or close Windows and drop to DOS, so that they could quickly rename a file or move it from one place to another. Sure, users could even then, click into the File Manager, select the file(s) they wanted to rename or move and drag them to the relevant location, but a lot of people were finding that DOS was still quicker to use if you knew the commands. If you spent a few days learning the basic commands of DOS, you could really use your PC efficiently, coupled with the graphical usefulness of Windows (ahem), you could cut workload down by a good deal. Even today, when using modern GUI O/S’s like Windows XP and Mac OS, I still finding myself going to Stargoing to Start>Run and typing incommand to access the DOS prompt to do something quickly. To the people who used the PC before the GUI ruled (circa 1995), typing a command even now is sometimes more efficient than using a drag and drop idea.

Imagine the following scenario:
You have 300 files in a folder (call the folder ‘work’), and within that f older you have 2 other folders, one called ‘old’ and one called ‘new’. Your task is to separate the files in work to the new and old folder. You must put the files that are older than 1 month into old, and the files less than 1 month into new. In a graphical file manager, you would need to right click each of the 300 files separately to find out their creation date, and then move each of the files one by one into their relevant folder. This operation is seriously time-consuming.
How’s about the command-line option: type in one line at the shell, and the files are automatically sorted into each folder, determined by todays date. Sure, you would know that you would have to type
find /usr -ctime +30 -exec ls -ld {} \;‘ to get it to happen, but hey, it’s still faster than going through 300 files.
There are yet many other reasons that you may want to have a CLI, for example, a User Administrator has 3 dead (crashed) programs on 3 different workstations across a building. He has two choices: Go run around the building like a headless chicken and kill the programs manually at each workstation, or sit at his desk and telnet into each machine, using the CLI, killing each of the programs, finishing the job 20 times faster.

What about a remote GUI though? – Nowadays with faster networks it is possible to run X or even an MS Windows Desktop over a network. Remember however, all that graphics has a large bandwidth requirement, and means performance is often pretty poor (especially from afar). At the CLI, most of the time you will barely notice whether you are local or remote.

If you start to use Linux a lot, you’ll start to find it’s a lot easier just to issue a direct command instead of clicking on a hundred different icons to do something you could do in one command at the CLI.
A common misconception (I don’t know why this is) about Linux is that it is completely text based, and the story could not be further from the truth, but I expect Linux to always hold onto it’s console, as it’s a highly useful tool, and whilst I probably use it more than your average user will, it’s still handy at some points for most, given a few hours to learn it’s power.

Some simple commands, you may recognize

GNU/Linux has a lot of commands, luckily though, you’ll probably only ever want to know around 10-15 of them for anything at the CLI.
You can find the files for these commands in folders like /bin and /usr/bin on your Linux box.
If you have used computers since at least the late 90s, then you will probably remember DOS, you’ll find that the syntax of DOS commands compared to UNIX commands are often similar, and even some of the commands themselves are the same. Have a look at this comparison table if you can remember any DOS commands:

DOS Command UNIX Counterpart What it does
dir dir or preferablyls Shows the files in the current folder
cls clear Clears the screen
type cat Shows the contents of a file, eg cat foo.txt
move mv Move a file from one place to another, eg: mv foo /home/
copy cp Copies a file, eg: cp /home/foo /users/foo
ren / rename mv The mv (move) command also doubles up for renaming
echo echo output (or echo) something to the screen

 

Some more commands, plus how to get help on almost any command
Here are a few more advanced commands, along with their explanations and one example for each:

Command Action Example
chmod Changes permissions for files chmod u=rwx myfile.txt
chown change the owner for a file or folder chown myuser /home/myfile.txt
chgrp change the group owner for a file or folder chgrp mygroup /home/myfile.txt
mv Moves or renames a file mv /home/me/myfile.txt /home/them/
grep searches text for results cat myfile.txt | grep “hello”
ls list the files in a folder ls -l
find finds files or file designators find /home -name “myfile.txt”
mount mounts a drive/block device for use mount /dev/cdrom /mnt/cdrom
ps Show the list of live processes ps ax | more
kill kill a process (running software) by process ID kill -9 12345
tar de facto Unix archiver tar zxvf myarchive.tar.gz
rpm The Red Hat Package manager, used to install, remove, upgrade and query RPM packages. rpm -Uvh mynewpackage.i386.rpm

 

Tux, The Linux Mascot

Tux Tip

Important tip:
If you ever need to know how to use a command, or just find out what a command does man (short for manual) is your friend. For example, by typing man ls, a comprehensive guide is given on using the ls command, what it’s purpose is and what it’s syntax is. For more information on using man, type man man.
There is not a better source for quick, easy to find information on almost every Linux command. The only times when man lets you down, is when you don’t know that a command that does a specific purpose exists, thus, you don’t know the name of the command, so you don’t know what manual page you want to ask man for. For this reason, I have started the lengthy process of creating a commands guide, that is easy to understand, although somewhat less verbose than manual pages themselves.

Be the first to comment on "I don’t know any commands"

Leave a Reply