You may also find this article of interest:
Setting Up a Full Powered SAMBA Server
A brief version of these commands also ran in my article for
Linux+ Magazine (lpmagazine.com).
Sitting in the freezing cold server room one evening, I
shared some tips with my colleague who was still learning server
administration.
|
|
As I typed several commands, and he wrote them down on the
back of his hand with a pen, I realized how much there is a need for a simple
printed list of the most frequently used Server administration commands. Not a
big list that expansively covers everything you need to do with a Linux server.
Instead, just a focused group of commands that will definitely help any server
admin get the job done.
So with this article I offer Linux administrators an easy
reference for those late nights in the cold server room. These basic linux
commands for server administration compile
into an effective list of commands
you can take into the server room.
|
at
This often ignored tool covers when you need a
very quick solution rather than modifying your cron tab. With this too you can
quickly run any command or process at a later time using a very easy to
understand syntax. For example, running as root type:
at midnight
Once you press enter you will see the at prompt. Beside the at> type a specific command. For example, to run a command at midnight tonight, start by typing:
at> who > who.out
Pressing enter again will ensure that this command will run at the
specified time frame (eg. midnight, noon, teatime, etc). Press the Ctrl and D keys simultaneously to exit the
at prompt.
You should now see:
X 2006-05-26 00:00 a name
The X represents the number assigned to your new at command. This
indicates that an automated process will run your specified command tonight at midnight (00:00).
If you decide, prior to midnight, not to run this command, then type:
atrm X
Ensure you replace the X with the number of your
command. The syntax allows you to many easy to remember time increments, such
as midnight, teatime, morning, noon, etc.
chkconfig
This is a very important
administrative command and I suggest you get well familiar with it. I have many details about this command as well as other server commands on my Linux Server Admin commands page.
The chkconfig command allows you to determine
whether core processes and daemons are active. I suggest using the following
syntax::
/sbin/chkconfig -list
This command provides a long list of processes with details of their status.
Any process with the word "off" next to it is disabled.
Troubleshooting issues with your server should begin with this command, which
clearly denotes if a daemon or process is running or off.
du
The display usage command allows you
to identify the size of files in specific directories. However, please do NOT
run this command from the / directory. It will display size for every file on
the entire hard disk within a specific directory.
I suggest you run this command from a specific sub-directory
by first changing directory, then using the syntax: du -a
df
The df command provides a quick check of your file system
disk space.
Type df -h -T to get a simplified output that includes your file system type
information. Notice that this command details all storage devices such as your
hard disk/s (hda, hdb etc.) and your server SWAP file (shm).
find
Find command allows you to locate
files quickly across an entire file system The most common syntax is:
find / -name filename -type
d -xdev
Please replace the word filename with the name of a specific file.
The example shown allows
you to search against all directories below / for the filename found in directories, but only on the existing
file system
free
A nice name for a quick command to
check system memory. It is useful when trying to determine the status of your
SWAP file during certain load instances. From the command line type:
free -l
I tend to run this command with the -l option as it helps determine where my low memory
and high memory stats are during peak loads or testing. Regardless how you use
it, you'll find this a handy command for basic memory statistics and
performance analysis.
grep
The grep command searches text files for a
particular word or string of words.
I have many details about this command as well as other server commands on my Linux Server Admin commands page.
The grep command can be very helpful when trying to find that
needle in a haystack, like a particular line in a large log file. Use the
syntax: grep textstring filename
lsof
This command is short for
"list open files." In the man pages it is properly documented as a method for
listing any form of open file, including for example "a network
file." But notice
that what this actually means it that you are able to list open sockets, and
even run in repeat mode allowing for time intervals between each pass. All that
to say this is a very powerful and useful command for admins. From the command
line you simply type: lsof
However, I tend to use this command to check open ports, and
to do so you simply type the command with the -i option followed by a specific
port number: lsof -i :443
netstat
The netstat command provides a summary status of all network
connections and sockets.
I find the most helpful syntax is
either: netstat
|head or to use netstat -r
Using
the -r option gives you a very good look at
the network routing addresses. This is directly linked to the route command.
top
You
may already be familiar with the top command. It is especially helpful since it displays system statistics
and details regarding active processes. Using
this command gives you a summary view of the system with a listing of users,
memory usage, CPU usage, and associated processes.
uptime
The
uptime command checks for your server's
total uptime statistics. Running this simple command is especially useful for
performance checking, since it will also display the average system load over
the past few minutes.
Mark Rais has written numerous articles on integrating Linux and Windows including his featured article Moving to Linux for Business. Besides serving as managing editor for reallylinux.com Rais also contributes as a technology consultant for educational and non-profit organizations.
Linux is a registered trademark of Linus Torvalds. Microsoft, Microsoft Windows, and WindowsXP Home Edition are trademarks or registered trademarks of Microsoft Corporation both in the United States and Internationally. All other trademarks or registered trademarks in this article belong to their respective owners.