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
: 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 www.redhat.com
Where <www.redhat.com> is the name or ip address of the host that you want to trace.
traceroute to www.portal.redhat.com (22.214.171.124), 30 hops max, 38 byte packets 1 ppp005.108-253-207.mtl.mt.videotron.net (126.96.36.199) 98.584 ms 1519.806 ms 109.911 ms 2 fa5-1-0.rb02-piex.videotron.net (188.8.131.52) 149.888 ms 89.830 ms 109.914 ms 3 ia-tlpt-bb01-fec1.videotron.net (184.108.40.206) 149.896 ms 99.873 ms 139.930 ms 4 ia-cduc-bb02-ge2-0.videotron.net (220.127.116.11) 99.897 ms 169.863 ms 329.926 ms 5 if-4-1.core1.Montreal.Teleglobe.net (18.104.22.168) 409.895 ms 1469.882 ms 109.902 ms 6 if-1-1.core1.NewYork.Teleglobe.net (22.214.171.124) 189.920 ms 139.852 ms 109.939 ms 7 126.96.36.199 (188.8.131.52) 99.902 ms 99.724 ms 119.914 ms 8 pos1-0-2488M.wr2.CLE1.gblx.net (184.108.40.206) 189.899 ms 129.873 ms 129.934 ms 9 pos8-0-2488m.wr2.kcy1.globalcenter.net (220.127.116.11) 169.890 ms 179.884 ms 169.933 ms 10 18.104.22.168 (22.214.171.124) 199.890 ms 179.771 ms 169.928 ms 11 pos8-0-2488M.wr2.SFO1.gblx.net (126.96.36.199) 159.909 ms 199.959 ms 179.837 ms 12 pos1-0-2488M.cr1.SNV2.gblx.net (188.8.131.52) 179.885 ms 309.855 ms 299.937 ms 13 pos0-0-0-155M.hr2.SNV2.gblx.net (184.108.40.206) 329.905 ms 179.843 ms 169.936 ms 14 220.127.116.11 (18.104.22.168) 2229.906 ms 199.752 ms 309.927 ms
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:
The above command will shut down the Apache server, Samba services, LDAP server, and DNS server respectively.
[root@deep] /# killall httpd smbd nmbd slapd named
clock on the top of your terminal: Edit the profile file, vi /etc/profile and add the following line:
The result will look like:
PROMPT_COMMAND='echo -ne "\0337\033[2;999r\033[1;1H\033[00;44m\033[K"`date`"\033[00m\0338"'
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
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME 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 deep.openna.com:netbios-ssn (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 deep.openna.com:netbios-ns nmbd 461 root 9u IPv4 470 UDP deep.openna.com:netbios-dgm 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 deep.openna.com:domain named 2599 root 23u IPv4 3094 TCP deep.openna.com:domain (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 mail.openna.com who
firstname.lastname@example.org'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.
: 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.