Advance Server Admin Command

IDevice Icon Advance Server Admin Command

Command

Summary Use

du

The du command prints a summary of the amount of information you have stored in your directories on the mounted disks.
syntax: du [options] path
ex: du -a /News

Options:
-s print the sum of bytes in your directories
-a print a line for each file in your directory

grep

The grep command searches text files for a particular word or string of words. Very helpful when trying to find that needle in a haystack, like a particular line in a large log file.
syntax: grep textstring filename(s)
ex: grep century history.text.doc

Head

Tail

head: prints the beginning of a text file
tail: prints the end of a text file
These commands allow you to view parts of a text file.
tail -n 5 textfile.txt
head -n 5 textfile.txt

The examples above will print the last 5 lines of the file textfile.txt and then the first 5 lines.

locate

Trying to find out where on your Linux server a particular file resides? Having a real nasty time doing it? If you have the Bash shell you can try using the locate command to identify where it is on your mounted drives.
Type: locate filename and press enter. Replace filename with the name of the file you are looking for. This is a real time saving command as you start navigating your Linux server!
If locate does not work for you try using which.

Nice

Nohup

Nice: runs programs/commands at a lower system priority
Nohup: runs nice programs even when you’re logged off the system
By using the two commands simultaneously, your large processes can continue to run, even when you have logged off the system and are relaxing.
Ex: nice nohup c program.c .
This command will allow the c compiler to compile program.c even when you have logged off the system.

ps

related to "stopped jobs"

The ps command displays all of the existing processes. This command is also directly linked to issues with stopped processes (also known as "stopped jobs").
Occasionally, you may see the message There are Stopped Jobs.
If you log off the system without properly stopping your jobs, some jobs/processes may remain in memory tying up the system and drawing unnecessary processing bandwidth.

Type ps and hit enter. This will list all of your current processes running, or stopped.

PID TT STAT TIME COMMAND
23036 pl S 0:00 -csh
23070 pl R 0:00 vi


The number under PID is the process identification number. To kill a process that is stopped, type: kill pid. Replace pid with the exact number of the process.
Ex: While in Vi, you accidentally press the wrong keys. Vi's operation is stopped and you are kicked back to the prompt. To kill the stopped Vi command, you may type: kill 23070.

stty

The stty command allows you to view a listing of your current terminal options. By using this command, you can also remap keyboard keys, tailoring to your needs.
Ex: stty and hit enter. This lists your terminal settings.
Ex: stty erase\^h . This remaps your erase key (backspace) to the Ctrl and h keys. From now on, holding down Ctrl and pressing h will cause a backspace. So you're scratching your head asking why is this handy? You'll see at some point how stty is also used for a number of other useful settings.

talk

In order to contact someone who is on the system, at the prompt you type: talk accountname . Replace accountname with the full account name of the person. If you don’t want anyone to disturb you using the talk command, at the prompt
type: mesg n. This prevents others from using talk to reach you.

tar

also related to gzip

You're bound to come across files that are g-zipped and tarred. Okay, now what? These are methods of compressing and storing directories and files in a single "file." Most new Linux programs come off the web as something like coolnew-game.4-4-01.gz. This file is likely a tar file that has then been gzipped for compression. The way to handle these files is simple, but requires that you put the file into an appropriate directory. In other words, don't plop the file in your root or /bin unless it belongs there.

Now you can do a one fell swoop un-gzip it and untar it into its original form (usually multiple files in many sub directories) by typing: tar -xvzf *.gz

This will programmatically un-gzip and then untar all files in the current directory into their full original form including sub-directories etc. Please be careful where and how you run this!

w

This command allows you to list all users’ and their processes who are currently logged in to the Linux server, or a particular user’s processes. Type: w to view all users’ processes. Type: w jsmith to view jsmith’s processes. We use this all the time from a system admin standpoint. Please also see more commands to get user information on this page. You need to know who logs on to your system! Okay, so you have a stand alone Linux box and no one else uses it? Try this command just to be sure. ;)

!!

Don’t waste time and energy retyping commands at the prompt. Instead, use the ! option. To automatically re-display the last command you typed at the prompt, type: !! and press enter. Press again to invoke the command. You can also automatically re-display a command you typed earlier by using the ! and the first few letters of the command.
Ex: At the Linux prompt you had typed the command clear, followed by the command pico, followed by the command ftp. In order to re-display the clear command you type: !cl and press enter. In order to re-display the last command you typed, simply type: !! . Try it out. You’ll find this a time saver when dealing with long commands. Especially commands like tar!