Appendix B. Tweaks, Tips and Administration tasks

Some of the tips in this section are specific to Linux systems. Most are applicable to UNIX system in general.


The du utility command: You can use the du utility to estimate file space usage. For example, to determine in megabyte the sizes of the /var/log/ and /home/ directory trees, type the following command:

[root@deep] /# du -sh /var/log /home

3.5M    	/var/log
350M    	/home

Keep in mind that the above command will report the actual size of your data. Now that you know for example that /home is using 350M you can move into it and du -sh * to locate where the largest files are.

[root@deep] /# cd /home/
[root@deep ]/home# du -sh *

343M    	admin
11k     	ftp
6.8M    	httpd
12k     	lost+found
6.0k    	named
6.0k    	smbclient
6.0k    	test
8.0k    	www

Tip: You can add this command to your crontab so that every day you get emailed the desired disk space list, and you'll be able to monitor it without logging in constantly.


Find the route: If you want to find out the route that the packets sent from your machine to a remote host, simply issue the following command:

[root@deep] /# traceroute

traceroute to (, 30 hops max, 38 byte packets
 1 (  98.584 ms  1519.806 ms  109.911 ms
 2 (  149.888 ms  89.830 ms  109.914 ms
 3 (  149.896 ms  99.873 ms  139.930 ms
 4 (  99.897 ms  169.863 ms  329.926 ms
 5 (  409.895 ms  1469.882 ms  109.902 ms
 6 (  189.920 ms  139.852 ms  109.939 ms
 7 (  99.902 ms  99.724 ms  119.914 ms
 8 (  189.899 ms  129.873 ms  129.934 ms
 9 (  169.890 ms  179.884 ms  169.933 ms
10 (  199.890 ms  179.771 ms  169.928 ms
11 (  159.909 ms  199.959 ms  179.837 ms
12 (  179.885 ms  309.855 ms  299.937 ms
13 (  329.905 ms  179.843 ms  169.936 ms
14 (  2229.906 ms  199.752 ms  309.927 ms
Where <> is the name or ip address of the host that you want to trace.


Display Web pages access: To display quickly the number of times your web page has been accessed use this command:

[root@deep] /# grep "GET / HTTP" /var/log/httpd/access_log | wc -l



Shut down most services altogether: As root, you can shut down most services altogether with the following command:

[root@deep] /# killall httpd smbd nmbd slapd named
The above command will shut down the Apache server, Samba services, LDAP server, and DNS server respectively.


clock on the top of your terminal: Edit the profile file, vi /etc/profile and add the following line:

PROMPT_COMMAND='echo -ne "\0337\033[2;999r\033[1;1H\033[00;44m\033[K"`date`"\033[00m\0338"'
The result will look like:

Clock on terminal window


lsof installed on your server?: If not, install it and execute lsof-i. This should list which ports you have open on your machine. The lsof program is a great tool as it will tell you which processes are listening on a given port.

[root@deep] /# lsof -i

Inetd	   344     root   4u  	IPv4    327        TCP 	 *:ssh (LISTEN)
sendmail   389     root   4u  	IPv4    387        TCP 	 *:smtp (LISTEN)
smbd       450     root   5u  	IPv4    452        TCP (LISTEN)
nmbd       461     root   5u  	IPv4    463        UDP 	 *:netbios-ns
nmbd       461     root   6u  	IPv4    465        UDP 	 *:netbios-dgm
nmbd       461     root   8u  	IPv4    468        UDP
nmbd       461     root   9u  	IPv4    470        UDP
named     2599	   root   4u  	IPv4   3095        UDP 	 *:32771
named     2599	   root   20u  	IPv4   3091        UDP 	 localhost.localdomain:domain
named     2599	   root   21u  	IPv4   3092        TCP 	 localhost.localdomain:domain (LISTEN)
named     2599	   root   22u  	IPv4   3093        UDP
named     2599	   root   23u  	IPv4   3094        TCP (LISTEN)


commands on remote servers via ssh protocol: The ssh command can also be used to run commands on remote systems without logging in. The output of the command is displayed, and control returns to the local system. Here is an example which will display all the users logged in on the remote system.

[admin@deep /]$ ssh who's password:
root	tty1	Dec  2 14:45
admin	tty2	Dec  2 14:45
wahib	pts/0	Dec  2 11:38


Filename Completion: Tab filename completion allows you to type in portions of a filename or program, and then press TAB, and it will complete the filename for you. If there's more than one file or program that starts with what you already typed in, it will beep, and then when you press TAB again it will list all the files that start with what you initially typed.


Special Characters: You can quickly accomplish tasks that you perform frequently by using shortcut keys one or more keys you press on the keyboard to complete a task. For example, special characters can be used on the Linux shell like the following:

  • Control+d: If you are in the shell and hit Control+d you get logged off.

  • Control+l: If you are in the shell and hit Control+l you clear the screen.

  • ?: This is a wildcard. This can represent a single character. If you specified something at the command line like "m?b" Linux would look for mob, mib, mub, and every other letter/number between a-z, 0-9.

  • *: This can represent any number of characters. If you specified a "mi*" it would use "mit", mim, miiii, miya, and ANYTHING that starts with mi. "m*l" could by mill, mull, ml, and anything that starts with an m and ends with an l.

  • [] - Specifies a range. if I did m[o,u,i]m Linux would think: mim, mum, mom if I did: m[a-d]m Linux would think: mam, mbm, mcm, mdm. Get the idea? The [], ?, and * are usually used with copying, deleting, and directory listings.

Important: Everything in Linux is CASE sensitive. This means "Bill" and "bill" are not the same thing. This allows for many files to be able to be stored, since "Bill" "bill" "bIll" "biLl", etc. can be different files. So, when using the [] stuff, you have to specify capital letters if any files you are dealing with have capital letters. Much of everything is lower case in UNIX, though.