|head||Send the first part of file to standard output. The following example shows
the first ten lines of the file file.txt.
head -n 10 file.txt
|id||Show user and group information for any user. For example,
[email@example.com ~]$ id root
uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),
This command is often used to check if a user name exists to verify whether there is a security breach. It is convenient to do a quick check while logging in as a non-root user. The user name if exists can also be found in the configuration file /etc/passwd (required root access to browse).
|ln||Creates hard link or symbolic (soft) link. Visit this page for more information on usage of ln.|
|locate||Shows all accessible files matching the search pattern.|
|ls||Shows the contents of a directory.
List all contents of the directory dir1 in long format with human-readable format. ls -alh /dir1
List the contents of your home directory by adding a tilde after the ls command.
List the contents of the root directory (entire file system on your server).
List the contents of the parent directory.
List the contents of all subdirectories within the current directory.
Only list the directories in the current directory.
ls -d */
|man||Formats and displays manual pages for command on screen one page at a time. A brief description of each command option is shown. Most commands do not provide examples. man ls shows how to use ls.|
|mkdir||Make a new empty directory. A directory having names not beginning with a slash is relative to the current directory. You will need root access to create directories where write access is not permitted.|
|more||more somefile displays the contents of the file somefile and
pauses the display when the screen is full. This command is useful to view long results
produced by other commands via the command pipe. The following example displays the
contents of the current directory one full-screen page at a time.
ls -alh | more
Press the space bar to scroll to the next full-screen page. Press the enter key to advance one line. Press Ctrl C to terminate the display. more also displays the approximate percentage of completion for very long output.
|mv||Rename or move file to a new location.
mv file1 file2 moves or renames file1 into file2, overwriting file2 if it exists.
mv -i file1 file2 moves or rename files and prompt for overriding if file2 exists, answer yes or no to the prompt to override or not.
mv filename ../ moves a file to its parent directory.
mv *.jpg ~ moves all files with the extension .jpg to the login directory.
mv * /dir1 moves all files and directories to the directory dir1.
mv -f /dir1 /dir2 moves or renames directory dir1 to dir2. The directory dir1 can contain files and subdirectories.
|newgrp||Log in to a new group.|
|pwd||Shows the present or current working directory.|
|rm||removes (deletes) files and directories. Use the option -r (recursively) to remove a directory and all its contents. For example, rm -rf /dir1 removes directory dir1 and all of its contents without prompting (-f, force option). You should always excersize extreme care when using this command while logging in as root. rm -rf / will delete the entire file system rendering the server useless.|
|rmdir||Removes empty directories. A directory having names not beginning with a slash is relative to the current directory. You will need root access to remove directories where write access is not permitted. A directory must be empty (not have any files or subdirectories) to be removed successfully.|
|sort||Sort the contents of a file based upon a specified criteria. This command is useful to sort the results produced by other commands via the command pipe.|
|stat||Shows current status of files and directories.
The following example shows vital statistics of a directory.|
[firstname.lastname@example.org ~]$ stat files/
Size: 4096 Blocks: 8 IO Block: 4096 directory
Device: 803h/2051d Inode: 9879584 Links: 2
Access: (0775/drwxrwxr-x) Uid: ( 501/ lxxx) Gid: ( 502/ lxxx)
Access: 2008-11-11 05:55:28.000000000 -0600
Modify: 2008-11-11 05:54:58.000000000 -0600
Change: 2008-11-11 05:55:15.000000000 -0600
The following example shows vital statistics of a file.
[email@example.com ~]$ stat teapot.jpg
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: 803h/2051d Inode: 9880163 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 501/ lxxx) Gid: ( 502/ lxxx)
Access: 2008-11-11 05:07:45.000000000 -0600
Modify: 2008-11-11 05:07:45.000000000 -0600
Change: 2008-11-11 05:52:52.000000000 -0600</td>
|tail||Send the last part of file to standard output. The following example shows
the last ten lines of the file file.txt.
tail -n 10 file.txt
|touch||Creates a 0-size file or to change the date and time of a file or
directory. This is useful to synchronize the date and time of specific
files after a package installation. Following are some examples:
Create an empty file.
Change time of a directory to current time and date.
touch -c bugs/
Create an empty file with a specific date and time.
touch oldfile -d '2008-09-30 12:00:00'
Create an empty file with another file's date and time.
touch oldfile -r 38.jpg
Create an empty file with a specified timestamp.
touch oldfile -t 200811031430.12
|wc||Counts lines, words and characters in file.
[firstname.lastname@example.org ~]$ wc bugs/te.txt
1 22 123 bugs/te.txt
|which||Shows the full (absolute) path of a specified Linux command.
This is useful to make sure that the commands are executed from their
correct location. To secure the integrity of a dedicated server, there
should be automated scripts to verify the locations of critical server
components if a security breach is suspected. The following examples
shows the actual location of the program povray.
[email@example.com ~]$ which povray