Tuesday, July 12, 2011

Overview of Linux :

Here we will try to cover topics like :

1. System Structure .
2. Logging in and Out.
3. Common Linux commands.

System Structures : 

It's basically divided into 3 parts : Kernel , Shell and The Directory Structure :

The Kernel : The kernel controls everything inside - out on a system that runs the linux OS.

The Shell : The shell is the interface between the user and the Kernel. User provides instructions to the shell, which are interperted and passed to the Kernel for processing.

Logging in and out :

Try logging using telnet and ssh to the server .

[root@instructor ~]# ssh instructor
root@instructor's password:
Last login: Tue Jul 12 15:09:34 2011 from 192.168.138.1

Common Linux Commands : 

Linux has many commands, we will try to cover as many as we can so that our daily administration task becomes very easy. 

Command Line ?? 
The command line refers to a linux command prompt where you enter commands for execution. 
Commands May or may not have arguments: 

Arguments ??
Arguments are used with commands for better, restricted or Enhanced output or for combination.

The basic syntax of command is : 

$ command argument1 argument 2 argument 3. 

===================================================
Command 01: ls
The ls commands displays list of files and directories and has many options attached to it which are mentioned below : 

ls -a            List hidden Files. 
ls -F            Displays file types. ( Shows ( / ) directories, ( * ) for executable,
                  (@ ) for symlink and nothing for text files.
ls -lh           Long listing with Filesize in Human Readable Format.
ls -l             used for checking permissions, link counts, size, date, time, etc.
ls -ld           To see permissions of a Directory. 
ls -R            To List the contents of of specified Directory and all its sub-dir.
ls -t             List all files sorted by Time and Date with newest file first.
ls -ltr           List all files sorted by Time and Date with Oldest file first.

----------------------------------------------------------------------------------------
[root@instructor ~]# ls -lt
total 56
drwxr-xr-x 2 root root  4096 Jul 12 15:08 Desktop
-rw------- 1 root root  1016 Jul 12 14:55 anaconda-ks.cfg
-rw-r--r-- 1 root root 29875 Jul 12 14:54 install.log
-rw-r--r-- 1 root root  3671 Jul 12 14:53 install.log.syslog

[root@instructor ~]# ls -ltr
total 56
-rw-r--r-- 1 root root  3671 Jul 12 14:53 install.log.syslog
-rw-r--r-- 1 root root 29875 Jul 12 14:54 install.log
-rw------- 1 root root  1016 Jul 12 14:55 anaconda-ks.cfg
drwxr-xr-x 2 root root  4096 Jul 12 15:08 Desktop

--------------------------------------------------------------------------------------
Command 02: pwd 
The pwd commands shows user's current working Directory. 

--------------------------------------------------------------------------------------
[root@instructor ~]# pwd
/root
-------------------------------------------------------------------------------------
Command 03: cd
The cd command is used to navigate the directory tree. 

cd /usr/bin        to change directory to /usr/bin.
cd                    to go back to home directory. 
cd ~                 to go back to home directory from anywhere. 
cd ..                 to go one directory up. 
cd -                  to switch between current and previous directory.

Command 04: tty
It displays the pseudo Terminal where you are logged in. 
-------------------------------------------------------------------------------------
[root@instructor ~]# tty
/dev/pts/1
-------------------------------------------------------------------------------------

Command 05: who
The who command displays information about all currently Logged users. 

Command 06:
The w command provide more details as compared to who cmd. 

Command 07:  whoami
Displays username of the user who executes this command. 

Command 08: logname 
The logname command show real user who logged in despite he has sudo's to switch his identity.

Command 09: id 
The id command displays a user's UID, username, GID, groupname and all secondary groups that a user is member. 
--------------------------------------------------------------------------------------
[root@instructor ~]# id
uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel)
-----------------------------------------------------------------------------------------

Command 10: groups 
The groups command displays all groups that a user is member of. 

Command 11: uname 
The uname command provides basic information about the system. 

uname -a            Complete system information. 
uname -s            Kernel name 
uname -n            Network node name 
uname -r             Kernel release. 
uname -m           Machine h/w name. 
uname -p            Processor type or unknown.
uname -i             H/W platform or unknown.

Command 12: hostname
It displays the system name. 

Command 13: clear
Clear the current screen

Command 14: date

Command 15: hwclock

Command 16: cal 

Command 17: uptime 

Command 18: which 
which command shows the absolute path of the command that will be executed if run without using the absolute path. 
---------------------------------------------------------------------------------------
[root@instructor ~]# which passwd
/usr/bin/passwd
---------------------------------------------------------------------------------------

Command 19: whereis 
whereis command displays the binary path, full path of command and man pages of the command.
---------------------------------------------------------------------------------------
[root@instructor ~]# whereis cat
cat: /bin/cat /usr/share/man/man1p/cat.1p.gz /usr/share/man/man1/cat.1.gz
----------------------------------------------------------------------------------------

Command 20: wc
wc commands displays number of lines, word and character contained in text file.
---------------------------------------------------------------------------------------
[root@instructor ~]# wc /etc/profile
  58  157 1029 /etc/profile

1st column indicates no of lines.
2nd column indicates no of words.
3rd column indicates no of character.
4th column indicates the file type.
--------------------------------------------------------------------------------------

Command 21: wall
Its used to broadcast the message to all the people logged into the server.


Command 22: man
man command is used for help and to obtain the information for any specific commands for which you are not completly aware.

Searching by keyword :
Sometimes you need to use a command but you dont know its name.
Then man -k and apropos command can help you find your command.

The man -k and apropos command, the search is performed in whatis database that contains details about commands and files, and it list all the man pages which include the specified keywords.

The whatis database is once in a day by /etc/cron.daily/makewhatis.cron script.
makewhatis command can be used to update whatis .
------------------------------------------------------------------------------------------
[root@instructor ~]# apropos password
chage                (1)  - change user password expiry information
chpasswd             (8)  - update passwords in batch mode
cracklib            (rpm) - A password-checking library.
crypt                (3)  - password and data encryption
------------------------------------------------------------------------------------------

man -f passwd 
passwd --help 
passwd -?












No comments:

Post a Comment