Sunday, 27 October 2013

Ubuntu Basic Commands

There are few simple commands in Ubuntu operating system those we should know before using any Ubuntu machine. These commands would be very helpful and are easy for Ubuntu machine maintenance.

Man Pages

Linux OS provides a command named "man" for reading manual pages in the system. These manual pages contains description of general commands, system calls functions, library functions, file formats conventions etc.
These pages provides insight information of above mentioned categories.

man <command_name>

Example:
If something (like printf() function in C language) is not clear, what it do, what is the use and what is the syntax of this function etc information can be found in printf man pages. Below command should be used for this purpose

man printf

Similary, if we are not clear about any command, what it is, its use, where to use etc info is available in the manual pages
Try: man sudo

Once the manual page is opened in the terminal, use letter "q" to exit from the manual page.
-------------------------------------------------------------------------------------

"Sudo" Importance

In order to do administrative tasks like install, remove or upgrade applications/software in the Ubuntu machine, the logged user should have administrator privileges.
For this purpose, Ubuntu environment provides a special command called "sudo" (Super Used DO), which will allows us to install/remove/upgrade and system maintenance.
In Ubuntu there is no way to log in as Admin user (log in as ROOT) to do above tasks. So, Ubuntu added this command specifically to support above tasks.

Installing any application/software
Use: sudo apt-get install <package_name>

Un-Installing any application/software
Use: sudo apt-get remove <package_name>

Upgrade system software/applications
Use: sudo apt-get upgrade

sudo command will run the commands in administrator mode.

In ubuntu, all the application software are available in repositories unlike windows machine where we need to carry the software in external storage.

So, when we use command "apt-get", it will search required software/s (<package_name>) in the repositories, get that software program and will install/upgrade it without user intervention. It will automatically install software for us.
Note: Our Ubuntu machine should have Internet connection to use this facility from Ubuntu.
-----------------------------------------------------------------------------------------

Tasksel:

Tasksel (Task select) is also a special command in Ubuntu environment to install set of packages in one go.
For example, if we want to install FTP server or printer server or DNS server, they require so many dependency packages to install in order one by one to work.
Instead of installing them manually one by one, Ubuntu environment provides scripts for us to do above tasks using tasksel command. These scripts will have all information about the software and installs all required packages.
So, we don't need to worry about the dependency packages need to install before installing desired program.

Use: sudo tasksel
Result: It will promt a window, where we can select the software need to install from pre-avialble software lists (ex: DNS server, FTP server, Email sever etc). Select the required options and click OK. Done. 

-----------------------------------------------------------------------------------------

Control the service:
We can restart/start/stop any service using below command

Use:

sudo /etc/init.d/<service_name> start
sudo /etc/init.d/<service_name> stop
sudo /etc/init.d/<service_name> restart
-----------------------------------------------------------------------------------------

TOP command

The command "top" is very much similar to task manager in windows system.
Using top command, we will see the data like CPU utilization and memory utilization per process and in addition processes info that are running etc.

Use: sudo top
Task Manager in the UNIX world.
We see process ids (PID), CPU utilization and memory utilization info.

Abort any process using command "kill"
Use: 
kill -9 <process_id>
or
pkill -9 <process_name>
---------------------------------------------------------------------------------------

Navigation:

Navigation between the directories are simple in linux environment using command "cd" (Change Directory)

Use:
cd <directory_name>
   -->means that change the current working directory to <directory_name>

cd /<directory_name>
  --> means that change the directory to <directory_name> under ROOT (/) directory.

Under ROOT, we do find the directories named "home", "etc" and others.
So, if we need to navigate to any directories under ROOT (/) then use slash (/) before that directory name
i.e.  cd /home

No comments:

Post a Comment

You might also like

Related Posts Plugin for WordPress, Blogger...