Tuesday, April 12, 2011

8 Linux Commands That Will Save Your Day


Linux is a free and open source kernel that powers a variety of operating systems for servers, desktops, laptops, netbooks, mobile phones, and many embedded devices. 


If you have your own Linux server, you have probably used SSH to access the command line on at least a few occasions when your web-based control panel simply would not suffice. The following are eight commands you can use in Linux that will save you time, energy, and maybe even money.


1. grep - While you could simply describe grep as a search tool, it is really so much more. You can filter long lists, scour documents for the most obscure detail, and make other commands behave differently according to your specifications.
example:

ls -al | grep make


2. ps - When you need to figure out exactly what is going with your server, ps is invaluable. In its most basic functionality, it lists processes (instances of programs currently running). With a few choice flags, you can view process IDs, memory and CPU usage, command names, and even parent and child processes.
example:
ps aux


3. locate - Lose something? There are more intricate ways to search with “find” or “grep”, but locate searches a pre-loaded database of all of your files, which makes it fast for those quick searches for misplaced files. In order to use it, you need to run updatedb to have the latest files indexed.
example:
locate money.html


4. top - Monitoring your system is critical. The ps command gives you every running process, but top only shows the most hungry of the bunch. If your server is running slowly, top may lead you straight to the culprit. It displays CPU usage, memory usage, system load, and much more.
example:
top


5. kill - Yes, this is a real command and perhaps your most powerful weapon. When a program is out of control or when an application freezes, kill will become your best friend. Using data from ps and top, you can determine which processes are causing trouble and what their PID (process ID is).
examples:
kill 23849killall pythonkill -9 23849


6. who - This is a very simple command with a very important purpose. When you are running a dedicated server, you will most likely have other users connecting to it. Even if you do not, it is a good idea to monitor user accounts in case hackers manage to penetrate your security. The simple who command will tell you which users are logged in and what time their sessions began.


7. history - You will probably repeatedly type the above-mentioned commands and many others as you manage your server. Every time you need to run them again, you could always type them, but if the command you typed was a lengthy string, that can get old very quickly. The history command shows you a list of your previous commands. In a Linux terminal, you can press the up arrow to navigate through the list or type “history” to get the full list. Use the “!” key to quickly execute a command associated with a particular history number.
examples:
history!75


8. cat - This command gives you a quick way to print the contents of a file on your console screen. It is designed for text-based files, and you can use it in combination with more, less, grep, and other commands to determine how the text is displayed. You can also use the “>” to save the output to another file.
examples:
cat testfilecat testfile | grep “important sentence”cat testfile | lesscat /proc/cpuinfo > /home/username/mycpuinfo


These Linux commands are common, and most web hosts, such as Manchester managed server company 34SP.com, provide them as part of their standard Linux server installations. The examples provided just scratch the surface of these powerful commands. To unlock their full potential, you should reference the manuals for each. You can read the manuals online or type “man” followed by the command name from your system shell (example: man grep).


Tavis J. Hampton is a librarian and writer with a decade of experience in information technology, web hosting, and Linux system administration. His freelance services include writing, editing, tech training, and information architecture.

Sharing is Caring:
By Seeraj Muneer with No comments

0 comments:

Post a Comment

  • Popular
  • Categories
  • Archives