Operation commands

This document provides a basic list of commands and how they can be used to perform basic operations.

This is by no means a full list of commands or switches.
Users requiring a list of switches or further explanation of command should consult the man pages.
There is a wealth of knowledge on how to use and what commands do can be obtained from www.google.com/linux
Some commands will need to be performed by root. Type su -, which will give you root status

Operation Commands

Operation Commands List

any_command /--help |more

Display a brief help on a command (works with most commands). "--help" works similar to DOS "/h" switch. The "more" pipe is needed if the output is longer than one screen.

[thesmartguy@wifitest ~]$ apropos --help
usage: apropos keyword ...

man topic

Display the contents of the system manual pages (help) on the topic. Try man man first. Press "q" to quit the viewer. The command info topic works similar and may contain more up-to-date information. Manual pages can be hard to read. Try any_command --help for short, easy to digest help on a command. If more info needed, have a look to the directory /usr/doc. To display manual page from a specific section, I may use something like in this example: man 3 exit (this displays an info on the command exit from section 3 of the manual pages).

[thesmartguy@wifitest ~]$ man apropos

apropos topic

Give me the list of the commands that have something to to do with my topic.

[thesmartguy@wifitest ~]$  apropos lsmod
lsmod (8) - program to show the status of modules in the Linux Kernel


List the content of the current directory. Under Linux, the command "dir" is an alias to ls. Many users have "ls" to be an alias to "ls --color".

[thesmartguy@wifitest ~]$ ls
Desktop power Fig 1.png power Fig 5.png power Fig 9.png toss
Documents power Fig 2.png power Fig 6.png pt Fig 5.png user
Downloads power Fig 3.png power Fig 7.png rc Fig 1.png workplace-tmp
lotus power Fig 4.png power Fig 8.png rc Fig 2.png

ls -al |more

List the content of the current directory, all files (also those starting with a dot), and in a long form. Pipe the output through the "more" command, so that the display pauses after each screenful

Example shows ls pointed at a specific directory normal use is from within a directory.

[thesmartguy@wifitest ~]$ ls -al user
total 12
drwxrwxr-x 3 thesmartguy thesmartguy 4096 Nov 10 18:44 .
drwx------ 41 thesmartguy thesmartguy 4096 Nov 19 09:33 ..
drwxrwxr-x 2 thesmartguy thesmartguy 4096 Nov 10 18:44 .expeditor
Displays hidden files marked with a dot.filename and file permission

cd directory

Change directory. Using "cd" without the directory name will take you to your home directory. "cd -" will take you to your previous directory and is a convenient way to toggle between two directories. "cd .." will take you one directory up.

[thesmartguy@wifitest ~]$ cd /etc
[hesmartguy@wifitest etc]$
Changed directory frome wifitest to etc.

cp source destination

Copy files. E.g., cp /home/stan/existing_file_name . will copy a file to my current working directory. Use the "-r" option (for recursive) to copy the contents of whole directories, e.g. , cp -r my_existing/dir/ ~ will copy a subdirectory under my current working directory to my home directory.

[thesmartguy@wifitest ~]$ cp toss /tmp

copies file named toss to tmp directory no confirmation will be received cd to tmp to confirm.

mcopy source destination

Copy a file from/to a DOS filesystem (no mounting necessary). E.g., mcopy a:\autoexec.bat ~/junk . See man mtools for related commands: mdir, mcd, mren, mmove, mdel, mmd, mrd, mformat ....

mv source destination

Move or rename files. The same command is used for moving and renaming files and directories.

[thesmartguy@wifitest ~]$ mv toss jimmit

This will rename toss = jimmit again no confirmation do a ls to check. by pathing command you can rename and send to another directory i.e. mv toss /tmp/jimmit

ln source destination

Create a hard link called destination to the file called source. The link appears as a copy of the original files, but in reality only one copy of the file is kept, just two (or more) directory entries point to it. Any changes the file are automatically visible throughout. When one directory entry is removed, the other(s) stay(s) intact. The limitation of the hard links are: the files have to be on the same filesystem, hard links to directories or special files are impossible.

ln -s source destination

Create a symbolic (soft) link called "destination" to the file called "source". The symbolic link just specifies a path where to look for the file. In contradistinction to hard links, the source and destination don't not have to tbe on the same filesystem. In comparison to hard links, the drawback of symbolic links are: if the original file is removed, the link is "broken", symbolic links can also create circular references (like circular references in spreadsheets or databases, e.g., "a" points to "b" and "b" points back to "a").

rm files

Remove (delete) files. You must own the file in order to be able to remove it. On many systems, you will be asked or confirmation of deleation, if you don't want this, use the "-f" (=force) option, e.g., rm -f * will remove all files in my current working directory, no questions asked.

[thesmartguy@wifitest ~]$ rm -f jimmit

Removes jimmit file again no confermation.

rm -r files

(recursive remove) Remove files, directories, and their subdirectories. Careful with this command as root--you can easily remove all files on the system with such a command executed on the top of your directory tree, and there is no undelete in Linux (yet).

[thesmartguy@wifitest ~]$ rm -rf /user/*

(Deletes files in user directory)

mkdir directory

Make a new directory.

[thesmartguy@wifitest ~]$ mkdir test
Makes directory test no confermation do ls command to check.

rmdir directory

Remove an empty directory.

[thesmartguy@wifitest ~]$ rmdir test

(No confermation)

cat filename | more

View the content of a text file called "filename", one page a time. The "|" is the "pipe" symbol (on many American keyboards it shares the key with "\") The pipe makes the output stop after each screenful. For long files, it is sometimes convenient to use the commands head and tail that display just the beginning and the end of the file. If you happened to use "cat" a binary file and your terminal displays funny characters afterwards, you can restore it with the command "reset".

[thesmartguy@wifitest ~]$ cat test
hello testing cat

less filename

Scroll through a content of a text file. Press q when done. "Less" is roughly equivalent to "more" , the command you know from DOS, although very often "less" is more convenient than "more".

find / -name "filename"

Find the file called "filename" on your filesystem starting the search from the root directory "/". The "filename" may contain wildcards (*,?).

locate filename

Find the file name of which contains the string "filename". Easier and faster than the previous command but depends on a database.
Use updatedb this will rebuild the database a cron job can be set up to update database daily or weekley


Run an executable in the current directory, which is not on your PATH. You may need to use chown a+x ./program_name first to make the application executable.

touch filename

Change the date/time stamp of the file filename to the current time. Create an empty file if the file does not exist.


Post a Comment