Linux / Ubuntu

Introduction to Linux Command Line-1

As name suggests, it is an introduction for people learning to use Linux System. It focuses on command-line usage. There are different GUI tools and programs are available to perform a particular task, you may use it. The benefit of learning command-line is that, if  you will learn the tools and tricks of the command line which are in many cases faster, more powerful, and more flexible than any GUI program.

Before learning Command-line usage, you should be familiar with some terms.

what is “the shell” ?

The shell is a program that takes your commands from the keyboard and gives them to the operating system to perform. In the old days, it was the only user interface available on a Unix computer. Nowadays, we have graphical user interfaces (GUIs) in addition to command line interfaces (CLIs) such as the shell.

On most Linux systems a program called ‘bash‘ (which stands for Bourne Again SHell, an enhanced version of the original Bourne shell program, sh, written by Steve Bourne) acts as the shell program. There are several additional shell programs available on a typical Linux system.

What’s an xterm, gnome-terminal, konsole, etc.?

These are called “terminal emulators.” They are programs that put a window up and let you interact with the shell. There are a bunch of different terminal emulators you can use. Most Linux distributions supply several, such as: xterm, rxvt, konsole, kvt, gnome-terminal, nxterm, and eterm.

Starting a Terminal

Your window manager probably has a way to launch programs from a menu. Look through the list of programs to see if anything looks like a terminal emulator program. In KDE, you can find “konsole” and “terminal” on the Utilities menu. In Gnome, you can find “color xterm,” “regular xterm,” and “gnome-terminal” on the Utilities menu. You can start up as many of these as you want and play with them. While there are a number of different terminal emulators, they all do the same thing. They give you access to a shell session. In Ubuntu Open  Start menu >> Accessories >> Terminal.

Basic Commands

ls

List directory contents.

ls -l

long listing with dates and permissions

ls -a

list all, including hidden files (hidden files start with a period)

cd

Change directory.

cd –

change to previous directory

cd ~

change to home directory

cd ..

change to parent directory

pwd

Print current (working) directory.

cp

Copy file(s).

cp -r somedir somedest

Copy recursively (directory and all contents).Type source name instead of ‘somedir’ and target name instead of ”somedest.

mv

Move (or rename) a file (or directory)

rm

Delete (remove) a file.

rm -r somedir

Delete recursively (directory and all contents). Type source name instead of ‘somedir’.

rm -ri somedir

Delete recursively, but prompt before each removal. Type source name instead of ‘somedir’.

rm -rf somedir

Delete recursively, never prompt. Type source name instead of ‘somedir’.

mkdir

Create directory.

rmdir

Remove (empty) directory.

cat

Print file contents (to console).

less

Scroll through file contents, one page at a time.

SPACEBAR to advance a page, B to go back a page, Q to quit, /pattern to search for pattern

exit

Close shell. If this is your login shell, you will log out.

shutdown -h now

To shutdown system now

These are just basics of linux command-line. if you want to know more commands, feel free to ask..

Follow Mohammed Safeer On twitter.

Advertisements

3 thoughts on “Introduction to Linux Command Line-1

  1. This very good to get person up and going. For a person new to Linux it can be a frightful thing to get into the command line but the way you presented the information it was easy to follow

  2. Quite a few here I didnt know, the one I use the most is !! as I’m always forgetting to add sudo to commands and !! just repeats what was typed last. Also does it make me lazy that I just open new shells (Ctrl, Alt, F1 etc) instead of opening terminal or am I doing something not recommended? Great post.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s