Friday, January 31, 2014

Linux Commands

About Linux
A Linux distribution is a collection of (usually open source) software on top of a
Linux kernel. A distribution (or short, distro) can bundle server software, system
management tools, documentation and many desktop applications in a central secure
software repository. A distro aims to provide a common look and feel, secure and

Linux Commands.

1. man $command

Type man followed by a command (for which you want help) and start reading. Press
q to quit the manpage. Some man pages contain examples (near the end).
paul@laika:~$ man whois
Reformatting whois(1), please wait...

2. man $configfile

Most configuration files have their own manual.
paul@laika:~$ man syslog.conf
Reformatting syslog.conf(5), please wait...

3. man $daemon

This is also true for most daemons (background programs) on your system..
paul@laika:~$ man syslogd
Reformatting syslogd(8), please wait...

4. man -k (apropos)

man -k (or apropos) shows a list of man pages containing a string.
paul@laika:~$ man -k syslog
lm-syslog-setup (8) - configure laptop mode to switch syslog.conf ...
logger (1) - a shell command interface to the syslog(3) ...
syslog-facility (8) - Setup and remove LOCALx facility for sysklogd
syslog.conf (5) - syslogd(8) configuration file
syslogd (8) - Linux system logging utilities.
syslogd-listfiles (8) - list system logfiles

6. whereis

The location of a manpage can be revealed with whereis.
paul@laika:~$ whereis -m whois
whois: /usr/share/man/man1/whois.1.gz
This file is directly readable by man.
paul@laika:~$ man /usr/share/man/man1/whois.1.gz


Working on Directory.


1.1. pwd
The you are here sign can be displayed with the pwd command (Print Working
Directory). Go ahead, try it: Open a command line interface (like gnome-terminal,
konsole, xterm, or a tty) and type pwd. The tool displays your current directory.
paul@laika:~$ pwd
/home/paul

1.2 cd
You can change your current directory with the cd command (Change Directory).
paul@laika$ cd /etc
paul@laika$ pwd
/etc
paul@laika$ cd /bin
paul@laika$ pwd
/bin
paul@laika$ cd /home/paul/
paul@laika$ pwd
/home/paul

1.3cd ~
You can pull off a trick with cd. Just typing cd without a target directory, will put
you in your home directory. Typing cd ~ has the same effect.
paul@laika$ cd /etc
paul@laika$ pwd
/etc
paul@laika$ cd
paul@laika$ pwd
/home/paul
paul@laika$ cd ~
paul@laika$ pwd
/home/paul

1.4 cd ..
To go to the parent directory (the one just above your current directory in the
directory tree), type cd .. .
paul@laika$ pwd
/usr/share/games
paul@laika$ cd ..
paul@laika$ pwd
/usr/share
To stay in the current directory, type cd . ;-) We will see useful use of the . character

representing the current directory later.

1.5 cd -
Another useful shortcut with cd is to just type cd - to go to the previous directory.
paul@laika$ pwd
/home/paul
paul@laika$ cd /etc
paul@laika$ pwd
/etc
paul@laika$ cd -
/home/paul
paul@laika$ cd -
/etc

1.6 absolute and relative paths
You should be aware of absolute and relative paths in the file tree. When you type
a path starting with a slash (/), then the root of the file tree is assumed. If you don't
start your path with a slash, then the current directory is the assumed starting point.
The screenshot below first shows the current directory /home/paul. From within this
directory, you have to type cd /home instead of cd home to go to the /home directory.
paul@laika$ pwd
/home/paul
paul@laika$ cd home
bash: cd: home: No such file or directory
paul@laika$ cd /home
paul@laika$ pwd

/home
When inside /home, you have to type cd paul instead of cd /paul to enter the
subdirectory paul of the current directory /home.
paul@laika$ pwd
/home
paul@laika$ cd /paul
bash: cd: /paul: No such file or directory
paul@laika$ cd paul
paul@laika$ pwd

/home/paul
In case your current directory is the root directory /, then both cd /home and cd
home will get you in the /home directory.
paul@laika$ pwd/
paul@laika$ cd home
paul@laika$ pwd
/home
paul@laika$ cd /
paul@laika$ cd /home
paul@laika$ pwd

/home

path completion

The tab key can help you in typing a path without errors. Typing cd /et followed by
the tab key will expand the command line to cd /etc/. When typing cd /Et followed by
the tab key, nothing will happen because you typed the wrong path (upper case E).
You will need fewer key strokes when using the tab key, and you will be sure your

typed path is correct
1.7 ls
You can list the contents of a directory with ls.
paul@pasha:~$ ls
allfiles.txt dmesg.txt httpd.conf stuff summer.txt
paul@pasha:~$


1 comment:

  1. you are listed very helpful linux commands and also listed Flights detailed thats are very cheap...i like it

    ReplyDelete

Tricks and Tips