Want to support HowtoForge? Become a subscriber!

How can I clear the shell window?

Use the commad:


or the keyboard shortcut:

[CTRL] + [L]

Creating image borders with ImageMagick convert

The command is:

convert -border 2x2 old.jpg new.jpg

This creates a new image (new.jpg) with a 2 pixel border from the image old.jpg.

To set the bordercolor to red, use this command:

convert -border 2x2 -bordercolor "#FF0000" old.jpg new.jpg

Get a list of the installed services

To get a list of the installed services on the shell, you may use this command (on Fedora, RedHat, CentOS, SuSE, and Mandriva):

chkconfig --list

Show all processes for a specific user

To view only the processes owned by a specific user, use the following command:


and replace [USERNAME] with the name of the user.

Making snapshots of the process table shown by the TOP command

To make a snapshot of the current process table, use the following command:

top -n 1 -b > /tmp/processtable.txt

You can now view the textfile with any text editor, e.g. pico or vi.

How do I search for a term in a file?

With the grep command.

If you want to find out if the term user is in /etc/httpd/conf/httpd.conf, you would run

grep -i user /etc/httpd/conf/httpd.conf

(-i makes the search case-insensitive).

Normally grep does not tell you the line number where it finds the term. If you want to find out the line number, run

grep -n -i user /etc/httpd/conf/httpd.conf

How do I find out who is logged in on my system?

You can find out about logged in users either by running


(Sample output:

server:~# who
root     pts/0        Nov 12 11:28 (




which gives more detailed output:

server:~# w
 11:29:49 up  2:19,  1 user,  load average: 0.02, 0.01, 0.00
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
root     pts/0    11:28    0.00s  0.08s  0.01s w

How do I edit files on the command line?

To edit files on the command line, you can use an editor such as vi. To open the file, run

vi /path/to/file

Now you see the contents of the file (if there is any. Please note that the file is created if it does not exist yet.).

The most important commands in vi are these:

Press i to enter the Insert mode. Now you can type in your text.

To leave the Insert mode press ESC.

first page
previous page