Beginners – Finding Things

Valic —  January 17, 2013 — Leave a comment

The following commands are used to find files.  If you don’t know approximately where they are you need more powerful tools to find files such as these:

Linux Command Description


This command shows the full path of shell commands found in your path. For example, if you want to know exactly where the grep command is located on the filesystem, you can type which grep.

The output should be something like: /bin/grep


Locates the program, source code, and manual page for a command. For example, to find out where ls and its man page are type: whereis ls.

The output will look something like: ls: /bin/ls /usr/share/man/man1/ls.1.gz


A quick way to search for files anywhere on the filesystem. For example, you can find all files and directories that contain the name firefox by typing: locate firefox.

To update the locate database run the following command: updatedb.


Find is a very powerful command, but sometimes tricky to use. It can be used to search for files matching certain patterns as well as many other types of searches.
Example: find . -name \*debThis example starts searching in the current directory  and all sub-directories looking for files with deb at the end of their names.

The following commands can be used to:

  • find out information about files
  • display files
  • copy, move or delete files
Linux Command Command Description
file This command shows you out what kind of file it is.

Example:  file /bin/ls will tells you that it is a Linux executable file.

cat Display the contents of a text file on the screen. Example: cat filelist.txt will display the contect of the file filelist.txt
head Display the first 10 lines of a text file. Example: head /var/log/messages This will display the first 10 lines from the messages log file.
tail Display the last 10 lines of a text file. Example:  tail /var/log/messagesThis will display the last 10 lines from the messages log file.
tail -f Display the last 10 lines of a text file and then output appended data as the file grows.

Example: tail -f /var/log/messages

cp Copies a file from one location to another. Example: cp file.txt /tmp
Thos commadn copies the file.txt file to the /tmp directory
mv Moves a file to a new location, or renames it. For example: mv file.txt /tmp
rm Delete a file. Example: rm /tmp/file.txt
mkdir Make Directory. Example: mkdir /tmp/mydirectory
rmdir Remove Directory. Example: rmdir /tmp/mydirectory
NOTE: You can practice these commands by yourself and find more about all commands using the man command.

Piping Commands Together

The pipe character “|”  is usually used to chain 2 or more commands. The pipe command will take the standard output (STDOUT) from the program that you are using and will sent as standard input (STDIN) for the command after the pipe.

Example: root@server:~# ls /var/log/ | grep mail

The “pipe” command will take the output of the ls command and “pipes” into the input of the grep command.

Redirecting Program Output to Files

There are situations when you want to save the output of a command to a file rather than displaying it on the screen or both save to a file and display. For instance if you want to create a file that contain a list of all files and directories from /var/www you can do something like this:

ls /var/www > www_list.txt

This will redirect the standard output to www_list.txt

Another similar command can be written so rather than creating a new file called www_list.txt to append the output to the end of the original file.

ls /var/www >> www_list.txt

  • > – if the file does not exist will be created,
  • >> – will append to the end of the file, and if the file does not exist will be created,
  • 2>> – will append only error to the file
  • 2>&1 – will redirect errors and the output in the same place.

The Linux filesystem is a tree-like hierarchy of directories and files. The base of the filesystem is the “/” directory, also known as the “root” . Linux filesystem mounts all disks underneath the / filesystem, not like DOS or Windows filesystems that can have multiple roots. The following table shows you the most common Linux directories:


In this directory we will find essential command binaries like bash, ls, ps, tar, and others.


Here are static files of the boot loader.


In here we can find device files. In Linux hardware devices are accessed just like other files.


Here are system configuration files


This is the location of users personal home directories. Continue Reading…

Beginners – How to get Help

Valic —  December 5, 2012 — Leave a comment

When you are stuck and need  help with a UNIX command the help is sometimes a few  keystrokes away! Help is typically built  into the commands themselves, available through online facilitate programs like man pages and info pages.

 1. Using the Help biult-in command:

Many commands and applications have simple help screens that can be displayed with special command flags. This flag usually is “-h” or “–help“.


cat –help

2. Using Man Pages

The best source of data for most commands is found within the manual pages. Theese are known asa man pages. To display a command’s man page  you need to type man command

Example: If you want to get help with the grep command just type man grep and the man page for the grep command will be displayed.

Continue Reading…

Page 3 of 41234