Ubuntu , SUSE , RedHat , Xandros and Linspire are doing a great job with Linux Desktop. But they’ve a long way to go, with more than 90% of Windows and around 5% of Apple only a small bite is left for them. However, the power of Linux is already proven in the server arena, currently it is powering many mission critical servers all around the world. It’s free, it’s reliable, it’s rock-solid and most importantly it’s open source. When I just started to work as an IT Engineer, I was a Windows guy. The word Unix/Linux used to scare me. Fortunately I was given a chance to learn and manage Linux Server in production environment. I was thrown into real life usage of Linux servers with live services like email, ftp, web and databases. From my experience I can say that it’s not as scary as it seems in the beginning. With some minor efforts it can be learned by any Windows users and admins.
I’ve written this guide to help beginners who’re interested in getting started with Linux. This should give you an overview of Linux and it’s basic commands.
Linux come in different flavors, with a wide range of choice. The first and very simple question of a newbie "Which flavor is best for me?" actually don’t have a straight forward answer. I believe different flavors of Linux are of personal choice. Here is an example (just an example) of how people choose Linux Distribution: If you are an expert and don’t need any paid support, then you might choose Debian or Gentoo. If you’re in a big organization which requires official support for everything they install, then maybe RedHat or SUSE is for you. Whichever distribution you choose the basic commands we’re learning here will apply. But I can say that for a new user Fedora, Ubuntu or SUSE should be a good choice to start with.
Most of the Linux distribution nowadays ships with a GUI installer and the installation process is straight forward. You can find the detailed, step-by-step installation manual for almost every distribution you plan to install in it’s web sites. Here are few installation links:
Fedora Core Installation Guide
If you have a local access to the Linux server, you can login to X-Windows, with Gnome or KDE and launch the terminal program or you can choose text based login. Following is an example of text based login prompt.
If you are given an account in a remote server you can access it with remote login methods like telnet, rlogin or ssh. The most popular and secure way to connect remotely is via ssh. For windows you can use PuTTY ssh client to login to the Linux server.
With correct username and password you’ll end up in your home directory.
Now that you’re logged in to the Linux Server. Here are some commands to play with.
Online manual pages. man provides help on how to use Linux commands. E.g. you know that command ls exists but are not sure of all the options (switches) it has, then just type man ls. It will print out the help with all the options on how to use the command ls.
List information about the file/directory. By default this command lists the information in current directory. In the following example we are combining 2 switches a and l. a means list all or do not hide entries starting with . (dot). And l means use a long list format.
Print Working Directory. This command displays your current directory with full path. This is useful specially when you are somewhere and want to know your current location. E.g. after you login to the system for the first time and you type pwd you’ll see something like this. So, now I know I’m located at /home/niranjan
Read a file. This command allows you to read a file and scroll through its contents. It is used together with a file you want to read. E.g if you want to read a text file file1.txt, then you type following:
[niranjan@new niranjan]$more file1.txt
You’ll see the contents of file1.txt on your screen. You can go to next page by pressing space bar and B will take you to back to the previous page.
Text editor. It can be used to create new files or edit existing text files. vi is a very powerful text editor but it’s quite difficult to use at the begining. Here an example of it’s simple usage; to create a new text file named hello.txt with contents Hello World!:
[niranjan@new niranjan]$vi hello.txt
It will take you inside a new, empty file hello.txt. Then press i which means insert text. After pressing i, you’ll see — INSERT — at the bottom of the screen. Go ahead and type Hello World!. After you’re done typing, save the file and exit by pressing Esc and :wq. Esc takes you out of the insert mode and :wq means write and quit. You can explore more on usage of vi by typing man vi to see its full usage manual
Change your password. To change your password just type passwd. It will ask your current password, where you provide your existing password and press enter. After this it will ask for the new password twice to double confirm your input.
Process Status. Gives a snapshot of the current processes. By default it will just report about the processes you’ve started after logging in but you can get more information with combination of different switches. In the following example you can see that I’m running bash shell, editing a file with vi and running the command ps to see the process status.
This command displays a listing of the most CPU-intensive tasks on the system in real time, and it can provide an interactive interface for manipulating processes. Useful information like who owns the process and how much percentage of cpu and memory are being consumed by that process are listed out. Following is the output of a top command.
Prints disk usage of each directory and sub-directory. It is useful when you want to check how much space you are occupying in the system. By default it lists out the usage in KB. Here is an example usage with the switch -h, which means to list the disk usage in human readable format like K, M or G (KB, MB or GB).
Disk free space. Reports the amount of free space available in the mounted file system. When invoked with the switch -h, it lists the information in human readable format. Gives the total size of mounted file system, used space, available space in (KB, MB or GB) and usage in percentage.
Shows all the users that are currently logged in to the system. It lists the user’s name, terminal line and login date and time. If the user is logged in remotely, then it displays the ip address of the user.
This command shows who is logged in to the system and what they’re doing. It also displays the ip address of the remote user in FROM.
Copy files within the same or different directories. The command cp leaves the original file intact E.g cp myfile myfile2 will create a copy of myfile with the name myfile2 within the current directory. Now we’ll have myfile and myfile2 with the same contents.
Move file or directory. This command is also used to rename the files and directories. In the following example mv myfile myfile2 will rename the myfile to myfile2. Now we have only one file called myfile2
Make directory. This command is used to create new directory. E.g. mkdir test creates a new directory named test.
Remove. Deletes files or directories. By default it will only remove files. You need to be very careful using this command because once deleted there’s no recycle bin to get them back. There’re very powerful switches that can be used with this command. You should check man rm for full usage. rm command without any switch removes the file without warning. Here is an example usage with the interactive switch -i, which will ask you to double confirm.
This command logs you out of the system.