Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
5 views

Linux Basic Commands

Uploaded by

sauravqw87
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Linux Basic Commands

Uploaded by

sauravqw87
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 49

Narendra Sharma

Study of Basic commands to understand Assistant Professor


the system and working of LinuX
IILM University, Gr. Noida
Operating
System
• Acts as an intermediary between the
user(s) and the computer hardware
• System software that controls the
components of the computer system and
coordinates the execution of all other
programs (applications).
• The Operating System (OS) is a resource
manager
• Allocates resources for tasks
• Allocates tasks to programs
• Manages space and time
• Controls the devices
How does the OS start?
When OS is installed, it is stored on the hard disk, a non-volatile memory.

Bootloader is a program that loads the kernel into RAM when the computer is
started.

Bootloader or bootstrap loader is stored in Read-only-Memory (ROM), EPROM or


Flash memory.
Programming Execution
Types of Operating System
• Users
• Single User
• Multi User
• Processing
• Uni processing
• Multi processing
• Timesharing system
• Multi-programming system
FOSS - Free Open-Source Software
Free – Means Liberty and is not related to Price or cost
 Open – Source code is available and anybody can contribute to the
development.
 Organization independent
4 Freedoms with FOSS
 Freedom to run the software anywhere
 Freedom to study how the programs work. i.e source code will be accessible
 Freedom to redistribute copies
 Freedom to improve the software
• If the software has all these 4 freedoms, then it is a FOSS
History of operating system

• 1. Multics – 1964

• 2. Unics – 1969

• 3. Minix – 1990

• 4. Linux – 1991
1. Multics

 Multiplexed Information and Computing Service


 Written in 1964
 Timesharing OS
 Last version was shut down on October 30, 2008
 Monolithic kernel
2. Unics
Uniplexed Information and Computing System

Later renamed as UNIX

Written in 1969

Ken Thompson, Dennis Ritchie were among the developers

Multi user, Multitasking, and timesharing

Monolithic kernel
What is Unix?
• A multi-task and multi-user Operating
System
• Developed by Ken Thompson in 1969 at
AT&T’s Bell Labs
• First version written in assembly language
• single user system, no network capability
• Thompson, Dennis Ritchie, Douglas Mcllroy
• rewrote Unix in C: processor/architecture
independent
• Ken Thompson (Unix)
General Characteristics of UNIX as
an OS & Multi-tasking
• Multi-user
• most versions of UNIX are capable of allowing multiple users to log onto the
system, and have each run multiple tasks.
• Over 50 Years Old
• UNIX is over 50 years old and it's popularity and use is still high.
• Large Number of Applications
• There are an enormous amount of applications available for UNIX operating
systems.
• They range from commercial applications such as CAD, Maya, WordPerfect,
to many free applications.
• Free Applications and Even a Free Operating System
All of the applications available under UNIX, many of them are free.
• Less Resource Intensive
• In general, most UNIX installations tend to be much less demanding on
system resources.
• Internet Development
• Much of the backbone of the Internet is run by UNIX servers.
UNIX
The layers of a UNIX system.
User
Interface
Flavors of UNIX
• These can be grouped into two categories:
Open Source and Proprietary
• Proprietary: (redistribution and modification
prohibited or restricted; not free)
• Solaris - Access to a Solaris UNIX server
(solaris.gl.umbc.edu) via SSH access.
• IRIX - There are a couple of IRIX machines in
the basement of the library, as well as server
access (irix.gl.umbc.edu) via SSH access.
• Mac OS X - no access currently available at
UMBC. and many others...
3. Minix

Minimal Unix
Developed by Tanenbaum developed
Mainly for educational purposes
Unix like OS, implemented with Microkernel. So the name
Minix
4. Linux
 A clone of Unix
 Developed in 1991 by Linus Torvalds, a Finnish graduate student
 Inspired by and replacement of Minix
 Linus' Minix became Linux
 Consist of
• Linux Kernel
• GNU (GNU is Not Unix) Software
• Software Package management
• Others
 Used in most the computers, ranging from supercomputers to embedded system
 Multi user
 Multi tasking
 Time sharing
 Monolithic kernel
Why Linux?
 A Linux Distribution has thousands of dollars worth of software for no cost.
 Linux operating system is reliable, stable, and very powerful
 Linux provides a complete development environment.
 Excellent networking facilities
 Ideal environment to run servers such as a web server, or an ftp server.
 A wide variety of commercial software is available if not satisfied by the free software
 Easily upgradeable.
 Supports multiple processors.
 True multi-tasking, multi-user OS.
 An excellent window system called X, the equivalent of Windows but much more flexible.
 Full source code is provided and free.
The GUIs are more powerful than Mac!
Which Linux Distribution is better?
• > 300 Linux Distributions
• Slackware (one of the oldest, simple and stable distro.)
• Redhat
• RHEL (commercially support)
• Fedora (free)
• CentOS (free RHEL, based in England)
• SuSe ( based in German)
• Gentoo (Source code based)
• Debian (one of the few called GNU/Linux)
• Ubuntu (based in South Africa)
• Knoppix (first LiveCD distro.)
• …
LINUX Distributions

Mandrake: http://www.mandrakesoft.com/
RedHat: http://www.redhat.com/
Fedora: http://fedora.redhat.com/
SuSE/Novell: http://www.suse.com/
Debian: http://www.debian.org/
Linux vs. Unix

• Linux is free, but Unix is not.


• Unix is compatible with Linux at the system
call level
• But Linux will run faster than Unix on the
same hardware.
Operating System INTRODUCTION

Design
Linux Commands

LINUX COMMANDS
CLASSIFICATION OF COMMANDS:
1. General Purpose Commands
2. Directory Commands
3. File Commands
4. Pattern Searching Commands
5. File Permission Commands
6. File compression, backing up, and restoring
7. Administrative Commands
8. Networking Commands
Linux Commands

GENERAL PURPOSE COMMANDS:


• Date - To display the current date and time
• Cal - To display the calendar
• Echo - To display the message on the screen.
• Who - To show the users currently logged on.
• Whoami - To know in which terminal the user is currently logged on
• Tty - To report the name of the device the user is currently using for a terminal
• Df - To show disk usage
• Man - It gives the online help to all commands with all options
• History - To print the recently used commands
• Clear - To clear the screen
Linux Commands

Directory COMMANDS:
• pwd - To display the pathname of the current working directory
• Mkdir - To create a new Directory
• Cd - To change from one directory (working) to another
• rmdir - To remove the existing directory
• Ls - To list out the names of all files in the current working directory


Linux Commands

File COMMANDS:
• Cat - To create a new file - $cat > <filename>
• - To append the file contents - $cat >> <filename>
• - To display the file contents - $cat <filename>
• - To concatenate the multiple files into a single file - $cat <file1> <file2> >> <file3>

• Sort - To sort the file contents in some particular order - $sort <filename>
• Cp - To copy a file to another file. - $cp <source file> <destination file>
• Mv - To move (rename) the contents of file to another -$mv <source file> <destination file>
• Rm - To delete a file permanently - $rm <filename>
• File - To find the type of file present in that particular directory - $file <filename>
• Wc - To count the number of lines, words and characters in a file - $wc <filename>
• Head - Displaying the top contents based on line number
• Tail - Displaying the bottom contents based on line number


Linux Commands

Pattern Searching COMMANDS:

• grep (global search for regular expression and print)


• - To search and display a line for a given word or given pattern
• - $grep <pattern> <filename>

• Pipes –
An important early development in Unix was the invention of "pipes," a way to pass the output of one tool to the
input of another.
eg. $ who | wc −l
By combining these two tools, giving the wc command the output of who, you can build a new command to list the
number of users currently on the system
Linux Commands
File Permission Commands
• Linux divides authorization into 2 levels.

1. Ownership

2. Permission

Ownership of Linux files


• Every file and directory on your Unix/Linux system is assigned 3 types of the owner, given below.

• User - A user is the owner of the file. By default, the person who created a file becomes its owner.
• Group - A user- group can contain multiple users. All users belonging to a group will have the same
Linux group permissions access to the file.
• Other - Any other user who has access to a file.
Linux Commands
File Permission Commands
Linux Commands
File Permission Commands
Linux Commands
File Permission Commands
Linux Commands
File Permission Commands
Linux Commands

File Permission Commands


chmod Change the file permissions.
Ex: chmod 751 myfile : change the file permissions to rwx for owner,
rx for group and x for others

chown Change owner.


Ex: chown <owner1> <filename> : Change ownership of a file to
owner1.

chgrp Change group.


Ex: chgrp <group1> <filename> : Change group of a file to group1.
Linux Commands
File compression, backing up and
restoring
compress - Compress data.
uncompress - Expand data.
cpio Can store files on tapes. to/from archives.
gzip - zip a file to a gz file.
gunzip - unzip a gz file.
tar Archives files and directories. Can store files and directories on
tapes.
Ex: tar -zcvf <destination> <files/directories> - Archive copy groups of
files. tar –zxvf <compressed file> to uncompress
zip – Compresses a file to a .zip file.
unzip – Uncompresses a file with .zip extension.
Linux Commands

Administrative Commands
apt - commands to install or remove a package.
sudo apt-get update
Sudo apt-get install packagename

su Command
The su command provides administrative access to another user. In other words, it
allows access of the Linux shell to another user.
Syntax: su <user name>

SUDO – Super User DO


Networking commands
Ifconfig ARP – Address Resolution Protocol
Hostname telnet - Log into a remote host machine.
PING
ftp - Transfer files using the File Transfer Protocol.
TRACEROUTE
netscape - Run the Netscape web browser.
NETSTAT
mail - Read your mail using an ancient command-line program.
DIG – Domain information groper
who - See who else is logged in.
NSLOOKUP
talk - Talk to someone else who is current logged in.
ROUTE
lp - Send a file or set of files to a printer.
HOST

11/29/2024 02:57 PM
Networking commands
• 1. ifconfig
• ifconfig utility is used to configure network interface parameters.
Mostly we use this command to check the IP address assigned to the
system.
• # ifconfig
• eth0 Link encap:Ethernet HWaddr 00:0C:29:28:FD:4C
• inet addr:192.168.50.2 Bcast:192.168.50.255 Mask:255.255.255.0
• inet6 addr: fe80::20c:29ff:fe28:fd4c/64 Scope:Link
• UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
• RX packets:6093 errors:0 dropped:0 overruns:0 frame:0
• TX packets:4824 errors:0 dropped:0 overruns:0 carrier:0
• collisions:0 txqueuelen:1000
• RX bytes:6125302 (5.8 MiB) TX bytes:536966 (524.3 KiB)

11/29/2024 02:57 PM
Networking commands
• 2. Hostname
• Hostname command is used to view the hostname of the
machine and to set the hostname.

• ubuntu@devopscube:~$ hostname
• devopscube.com
• ubuntu@devopscube:~$

11/29/2024 02:57 PM
Networking commands
• 3. PING Command
• PING (Packet INternet Groper) command is the best way to test connectivity
between two nodes. Whether it is Local Area Network (LAN) or Wide Area
Network (WAN).

• # ping 4.2.2.2
• PING 4.2.2.2 (4.2.2.2) 56(84) bytes of data.
• 64 bytes from 4.2.2.2: icmp_seq=1 ttl=44 time=203 ms
• 64 bytes from 4.2.2.2: icmp_seq=2 ttl=44 time=201 ms
• 64 bytes from 4.2.2.2: icmp_seq=3 ttl=44 time=201 ms
• OR
• # ping www.tecmint.com
• PING tecmint.com (50.116.66.136) 56(84) bytes of data.
• 64 bytes from 50.116.66.136: icmp_seq=1 ttl=47 time=284 ms
• 64 bytes from 50.116.66.136: icmp_seq=2 ttl=47 time=287 ms
• 64 bytes from 50.116.66.136: icmp_seq=3 ttl=47 time=285 ms

11/29/2024 02:57 PM
Networking commands
• 4. TRACEROUTE Command
• traceroute is a network troubleshooting utility which shows number of hops taken to reach
destination also determine packets traveling path.
• # traceroute 4.2.2.2
• traceroute to 4.2.2.2 (4.2.2.2), 30 hops max, 60 byte packets
• 1 192.168.50.1 (192.168.50.1) 0.217 ms 0.624 ms 0.133 ms
• 2 227.18.106.27.mysipl.com (27.106.18.227) 2.343 ms 1.910 ms 1.799 ms
• 3 221-231-119-111.mysipl.com (111.119.231.221) 4.334 ms 4.001 ms 5.619 ms
• 4 10.0.0.5 (10.0.0.5) 5.386 ms 6.490 ms 6.224 ms
• 5 gi0-0-0.dgw1.bom2.pacific.net.in (203.123.129.25) 7.798 ms 7.614 ms 7.378 ms
• 6 115.113.165.49.static-mumbai.vsnl.net.in (115.113.165.49) 10.852 ms 5.389 ms
4.322 ms
• 7 ix-0-100.tcore1.MLV-Mumbai.as6453.net (180.87.38.5) 5.836 ms 5.590 ms 5.503 ms
• 8 if-9-5.tcore1.WYN-Marseille.as6453.net (80.231.217.17) 216.909 ms 198.864 ms
201.737 ms
• 9 if-2-2.tcore2.WYN-Marseille.as6453.net (80.231.217.2) 203.305 ms 203.141 ms
202.888 ms
• 10 if-5-2.tcore1.WV6-Madrid.as6453.net (80.231.200.6) 200.552 ms 202.463 ms
202.222 ms
11/29/2024 02:57 PM
Networking commands
• 5. NETSTAT Command
• Netstat (Network Statistic) command display connection info,
routing table information etc. To displays routing table
information use option as -r.

• # netstat -r
• Kernel IP routing table
• Destination Gateway Genmask Flags MSS Window
irtt Iface
• 192.168.50.0 * 255.255.255.0 U 00 0
eth0
• link-local * 255.255.0.0 U 00 0 eth0
11/29/2024 02:57 PM
• default 192.168.50.1 0.0.0.0 UG 00 0
Networking commands
• 6. DIG Command
• Dig (domain information groper) query DNS related information
like A Record, CNAME, MX Record etc. This command mainly use
to troubleshoot DNS related query.

• # dig www.tecmint.com; <<>> DiG 9.8.2rc1-RedHat-9.8.2-
0.10.rc1.el6 <<>> www.tecmint.com
• ;; global options: +cmd
• ;; Got answer:
• ;; ->>HEADER<

11/29/2024 02:57 PM
Networking commands
• 7. NSLOOKUP Command
• nslookup command also use to find out DNS related query. The
following examples shows A Record (IP Address) of tecmint.com.
• # nslookup www.tecmint.com
• Server: 4.2.2.2
• Address: 4.2.2.2#53
• Non-authoritative answer:
• www.tecmint.com canonical name = tecmint.com.
• Name: tecmint.com
• Address: 50.116.66.136

11/29/2024 02:57 PM
Networking commands
• 8. ROUTE Command
• route command also shows and manipulate ip routing table. To
see default routing table in Linux, type the following command.

• # route
• Kernel IP routing table
• Destination Gateway Genmask Flags Metric Ref
Use Iface
• 192.168.50.0 * 255.255.255.0 U 0 0 0 eth0
• link-local * 255.255.0.0 U 1002 0 0 eth0
• default 192.168.50.1 0.0.0.0 UG 0 0 0 eth0
11/29/2024 02:57 PM
Networking commands
• 9. HOST Command
• host command to find name to IP or IP to name in IPv4 or IPv6
and also query DNS records.
• # host www.google.com
• www.google.com has address 173.194.38.180
• www.google.com has address 173.194.38.176
• www.google.com has address 173.194.38.177
• www.google.com has address 173.194.38.178
• www.google.com has address 173.194.38.179
• www.google.com has IPv6 address 2404:6800:4003:802::1014

11/29/2024 02:57 PM
Networking commands
• 10. ARP Command
• ARP (Address Resolution Protocol) is useful to view / add the
contents of the kernel’s ARP tables. To see default table use the
command as.

• # arp -e
• Address HWtype HWaddress Flags Mask
Iface
• 192.168.50.1 ether 00:50:56:c0:00:08 C
eth0

11/29/2024 02:57 PM
Text editors
• Vi
• nano
• Emacs
• gEdit
• kWrite
• TextPad
• And more…
VI Editor
• Popular text editor
• Just type vi <<filename>> at the prompt and hit the
enter key.
• A new file will be opened
• Type the contents needed and save
• To save, press the Esc Key and then press : (colon) w q
and then enter
• To quit with out saving Esc + : + q and then enter
Vi • Delete
• 2 modes • dd (delete a line)
• Input mode • d10d (delete 10 lines)
• ESC to back to cmd mode • d$ (delete till end of line)
• Command mode • dG (delete till end of file)
• Cursor movement • x (current char.)
• h (left), j (down), k (up), l (right) • Paste
• ^f (page down) • p (paste after)
• ^b (page up) • P (paste before)
• ^ (first char.) • Undo
• $ (last char.) • u
• • Search
G (bottom page)
• /
• :1 (goto first line)
• Save/Quit
• Swtch to input mode
• :w (write)
• a (append)
• :q (quit)
• i (insert)
• :wq (write and quit)
• o (insert line after
• :q! (give up changes)
• O (insert line before)
INTRODUCTION

You might also like