Monday, July 9, 2007

Most frequently used Linux commands

I am .NET developer because the company, i work for, is partner of Microsoft.
I am fan of Open Source because i don't have money to pay for licenses.

I am not expert or geek in Linux, but i have certain experience managing linux systems as a server. Connection from remote through secure shell, running few commands, and it was all that i do. Actually you don't need to know much details, many commands. When you have problem, you just google to find whatever you wish. Being geek in linux is just same as being connected to internet anymore.

I recently installed Ubuntu Feisty on my toshiba laptop(satellite A50) to start using linux as my desktop. Let me say that my mouth was wide open after installation. Everything was there what i needed. Missing or additional softwares can easily be installed using just one line of command; "apt-get". Years ago, i was reading 4 pages of tutorials to setup LAMP environment on linux servers, but now just 4 lines of command to do the same task.
  1. Install Apache:
    sudo apt-get install apache2
  2. Install PHP5:
    sudo apt-get install php5-common php5 libapache2-mod-php5
  3. Install MySQL:
    sudo apt-get install mysql-server mysql-client
  4. To use MySQL with PHP:
    sudo apt-get install php5-mysql
It is magic, isn't it? You even don't need to write these lines, using Package manager tools, you can easily do the same tasks. So what i mean is, to use Linux as a desktop system, you don't have to know all the shell commands and stay sleepless for nights. The only and most used shell commands you should know is following;

1) ls
Most used command. To list current directory contents. Dir equivalent of Windows

2) find
If you don't remember where you did save your files, you can use this command to search. Find command have various parameters showing the behaveor of search. For example; my most used form is - find /usr -name f* which means to search from usr directory for files started with "f"

3) man
Manual for commands. Useful when you don't remember the parameters or usage, you can apply for man command. "man find" gives you help about find command.

4) vi
Text editor used by linux geeks, i don't like it. I use gedit in gnome environment. Or pico :)

5) cat
Useful command when you want to look at the content of text files. cat xxx.txt

6) more
If you standard output is more than one line, you can use more to page the result. Press space button to go to next page. cat xxx.txt | more

7) grep
Used to search for certain strings or patterns in text files. For example; grep “passwd” xxx.txt search for "passwd" string in xxx.txt file.

8 ) chmod, chown
In linux filesystem, all files have three kinds of permissions(read, write, execute) for three kinds of roles(me, group, eveyone); These commands used to change owner or permission of files. For example; chmod +x script.sh will make the script.sh file executable.

9) ps
To see what background or foreground processes are working. You can see the process id and use "Kill -9" to stop the process.

10) cp, mv, rm
Used to copy, move, delete files and directories. Usage is same as you do in Windows shell.


Find plenty of commands from the following resources;

See Also;
  1. Valuable Resources for Linux Sysadmins
  2. Run your asp.net application on Linux
  3. Looking for Free PHP/MySQL Web Hosting?
  4. Looking for Light WebServer?
  5. Learning Resources for Python Language

1 comment:

xlq said...

Be careful with this:
find /usr -name f*
The shell will expand f* if possible, meaning the command will behave unexpectedly. Use single or double quotes:
find /usr -iname "f*"