u Linux is one of the popular version of UNIX operating System.
uIt is open source as its source code is freely available.
uIt is free to use.
u An operating system is a program that acts as an interface between the user and the computer hardware and controls the execution of all kinds of programs.
u In technical terms, it is a software which manages hardware. An operating System controls the allocation of resources and services such as memory, processors, devices and information.
General Classification of Linux commands:
File System Commands
Process Management commands
File Permission commands
Secure Shell (SSH) commands
System Info commands
File Compression commands
u Following are some of the important features of Linux Operating System.
u Portable – Portability means software can work on different types of hardware.
u Open Source – Linux source code is freely available and it is a community based development project. Multiple team’s works in collaboration to enhance the capability of Linux operating system and it is continuously evolving.
u Multi User – Linux is a multiuser system means multiple users can access system resources like memory/ ram/ application programs at same time.
u Multiprogramming – Linux is a multiprogramming system means multiple applications can run at same time.
u Hierarchical File System – Linux provides a standard file structure in which system files/ user files are arranged.
u Shell – Linux provides a special interpreter program which can be used to execute commands of the operating system. It can be used to do various types of operations, call application programs etc.
u Security – Linux provides user security using authentication features like password protection/ controlled access to specific files/ encryption of data.
u Linux System Architecture is consists of following layers
u Hardware layer – Hardware consists of all peripheral devices (RAM/ HDD/ CPU etc).
u Kernel – a Core component of Operating System, interacts directly with hardware, provides low-level services to upper layer components.
u Shell – An interface to the kernel, hiding the complexity of kernel’s functions from users. Takes commands from the user and executes kernel’s functions.
u Utilities – Utility programs giving user most of the functionalities of operating systems.
Linux Basic Commands:
What is Command?
A command is an instruction given by a user telling a computer to do something or Command is nothing but Standard Input, Standard Output and Standard Error.
# Who– List users logged into the server
#pwd– Show the “present working directory”, or current directory.
#cd– Change current directory to your HOME directory.
#cd..– Change current directory to the parent directory of the current directory.
#cd.– Current directory
#ls– list a directory
#ls –l– list a directory in long (detailed) format
#ls –a– List the current directory including hidden files. Hidden files start with “. “
# mkdir <dir name>– Creates Directory
# rmdir <dir name>– Removes Directory
#more– Look at file, one page at a time
#touch <file name>– Creates empty text file with 0 bytes
# cat > <file name>– Create and type file
ctrl + d save & end the file
# cat <file name >– List the contents of the file
#rm –r <dir name>– Delete directory and its contents
# rm <file name>– Delete the file
#cp file1 file2– copy a file
# cp /tmp/test /var– Copy tes file to var directory
# cp /tmp/test /var/test– Copy test file to var dir with same name (test)
# mv <source> <destination>– Move file/directory
# mv /tmp/test /var– Move test file to var directory
# mv /tmp/test /var/test– Move test file to var dir with same name (test)
# mv /tmp/test /var/test5– Move test file to var dir and rename it as test5
File System Commands:
• $ ls Directory Listing
• $ls – al Formatted listing with hidden files
• $cd <<directory path>> Change directory
• $cd Change to home directory
• $pwd Show current directory
• $Mkdir <<directory name>> Create directory
• $rm file delete file
• $rm –r <<dir>> delete directory
• $rm –f <<file name>> force remove file
• $rm –rf <<dir>> Force remove directory
• $cp file1 file2 Copy file1 to file2
• $cp –r <<dir1>> <<dir2>> Copy dir1 to dir2. Create dir2 If It doesn’t exist
• $mv file1 file2 Remove or move file1 to file2.
If file2 is an existing directory
Move file1 into directory file2
• $touch file Create or update file
• $cat > file Places standard input into file
• $more file Output the contents of file
• $head file Output the first 10 lines of file
• $ nano file Open file in the Nano editor
Process Management Commands:
• $ps Display your currently active processes
• $top Display all running processes
• $kill pid kill process id pid
• $killall proc kill all processes named proc*
• $bg Lists stopped or background jobs; resume a
stopped job in the background
• $fg brings the most recent job to the foreground
• $fg n brings job n to the foreground
File Permission commands:
$chmod octal file Change the permissions of file to octal, which can be found separately for user, group, and world by adding:
Ø 4 – Read (r)
Ø 2 – Write (w)
Ø 1 – Execute (x)
7 — Total
$ chmod 777 sample.log Read, write and execute for all for file sample.log
• $grep pattern files – search for pattern in files
• $grep -r pattern dir – search recursively for pattern in dir
• $command | grep pattern – search for pattern in the output of command
• $locate file – find all instances of file
System Info commands:
• $date – show the current date and time
• $cal – show this month’s calendar
• $uptime – show current uptime
• $w – display who is online
• $whoami – who you are logged in as
• $finger user – display information about user
• $uname -a – show kernel information
• $cat /proc/cpuinfo – cpu information
• $cat /proc/meminfo – memory information
• $man command – show the manual for command
• $df – show disk usage
• $du – show directory space usage
• $free – show memory and swap usage
• $whereis app – show possible locations of app
• $which app – show which app will be run by default
File Compression commands:
• $tar cf file.tar files – create a tar named file.tar containing files
• $tar xf file.tar – extract the files from file.tar
• $tar czf file.tar.gz files – create a tar with Gzip compression
• $tar xzf file.tar.gz – extract a tar using Gzip
• $tar cjf file.tar.bz2 – create a tar with Bzip2 compression
• $tar xjf file.tar.bz2 – extract a tar using Bzip2
• $gzip file – compresses file and renames it to file.gz
• $gzip -d file.gz – decompresses file.gz back to file
• $ping host – ping host and output results
• $whois domain – get whois information for domain
• $dig domain – get DNS information for domain
• $dig -x host – reverse lookup host
• $wget file – download file
• $wget -c file – continue a stopped download
• $sudo apt-get install <<package name>> – Installs the package in ubuntu.
• $sudo yum install <<package name>> – Installs the pakage in CentOS