Ubuntu 8.04.2, PuTTY
I assume you know how to login and logout from Linux system and one Linux system is available in your network. Since this tutorial is based on admin commands, you should have access to the system with root privilege. For connecting to Linux you need any Telnet/SSH client like PuTTY. If you don’t have one yet, download PuTTY from the following site.
OK, open your client, give host name/IP address and press Open button. First Linux asks for user name and then password. Give the information and you are now in command prompt.
cat /etc/issue :-
The above command gives useful information about Linux distribution and version. There are so many distributions available like RedHat, Debian, Ubuntu etc.
This is the common command everybody execute to know the IP address of the system along with other network related information. The inet addr key speaks about IP address. This command resides in /sbin and if this is not in path, you have to execute /sbin/ifconfig command.
The above command gives information about currently running processes in Linux system. ps -e shows all processes. Every process in Linux is identified by a unique identification number. This command throws insight into process identification number, command, terminal etc. Processes may have parent process id where each process is originated from other process. Optional attribute -f prints information about parent process also. Just type ps -ef and hit enter.
Suppose you want to stop a process immediately. For eg, stopping MySQL database which is running on your system. Kill command stop processes. It works with ps command where you get process id. The syntax of kill command is give as follows.
kill <process id>
Please note that if you kill parent process, all child processes are also killed.
free : –
The free command shows details about memory usage, free memory available etc. It provides details about memory used for buffering, caching etc and also information about swap space. Swap space is disk area allocated for memory usage in case memory requirement exceeds RAM. buffers/cache is used to store data in memory so that it allows fast access later. Just type free -m and hit enter. -m attribute prints memory details in MB.
df command is used to show information regarding available disk space. It prints information regarding mount point, used disk apace, remaining space etc. Type df -m in the command prompt and hit enter. -m attribute shows space in MB.
Suppose your system is running out of memory or show slow responses. You may want to investigate which process is taking too much memory and CPU. Here comes this command for your rescue. Once top window is running, you may execute interactive commands. For eg, if you type M, it sort processes based on memory usage in descending order. Type top and hit enter.
While top is running, type M. This sort processes based on memory usage and first record is the one which takes maximum memory. Similarly P sort by CPU usage. You may give q command to exit from top window.
As a developer you may face situations where you have to install applications on your Linux system. Almost all installers are packaged as compressed archive files (.tar.gz). Before installing the application you have to decompress and extract the file. tar command helps to decompress and compress archive files.
For eg, tar -zxvf mysql-debug-5.0.0-alpha-pc-linux-i686.tar.gzdecompress and extract the files to mysql directory.
Similary you may want to package your files in .tar.gz format. Keep all files in a directory and issue tar command. Suppose you have a folder with name Projects. It consists of around 100 files. You may type the command like following,
tar -zcvf Project.tar.gz Projects
The above command creates a compressed archive file with name Project.tar.gz
Imagine you have multiple Linux systems in your network and you want to copy some files from one host to another. scp command helps to achieve this goal. For eg,
scp example firstname.lastname@example.org:/usr/local/
copies file example from current system to another system with IP address 192.168.8.124. It copies file to /usr/local directory of remote system. It asks for password for user root to connect to remote system. Once you supply the password, the files are copied securely. You may copy a directory using attribute -R
This command changes the ownership of files and directories in Linux system. In some cases you may want to allow full access to a directory for another user. In this case you way execute this command.
chown –R jinoy /usr/local/mysql, this command changes the ownership of /usr/local/mysql directory and its files to user jinoy.
Ok, let us stop here. There are many commands left to explain but I will do the same in separate tutorial in future.