0% found this document useful (0 votes)
15 views17 pages

Linux Lecture4

The document provides a comprehensive overview of various Linux commands categorized into filesystem management, network management, system management, and job/process management. Each command is briefly described along with its usage examples. This serves as a quick reference guide for users to manage filesystems, network configurations, system operations, and processes in Linux.

Uploaded by

Alelgn Asnakie
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views17 pages

Linux Lecture4

The document provides a comprehensive overview of various Linux commands categorized into filesystem management, network management, system management, and job/process management. Each command is briefly described along with its usage examples. This serves as a quick reference guide for users to manage filesystems, network configurations, system operations, and processes in Linux.

Uploaded by

Alelgn Asnakie
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 17

Linux Commands

Linux Filesystem Management


badblocks Used to search a disk or partition for
badblocks. (badblocks device) (badblocks sda)
df Shows the disk free space on one or more filesystems.
(df –k, df -h)
du Shows how much disk space a directory and all its
files contain. (du <directory>, du –sk <directory>, du –sh
<directory>)
fsck Filesystem check. Must not be run on a mounted file
system. (fsck <filesystem>)
Linux Commands

Linux Filesystem Management


sync Synchronize data on disk with memory. `sync'
writes any data buffered in memory out to disk.
mount Used to mount a filesystem. Complement is
umount. (mount <filesystem>, mount –a)
umount Unmounts a filesystem. Complement is mount.
(umount <filesystem>)
Linux Commands

Network Management Commands

dnsdomainname Show the systems DNS domain name


hostname Used to show or set the name of your machine
for networking
nisdomainname Show or set systems NIS/YP domain
name
ypdomainname Show or set the system's NIS/YP domain
name
Linux Commands

Network Management Commands

arp This program lets the user read or modify their arp
cache.
dig Send domain name query packets to name servers
for debugging or testing.
finger Display information about the system users. Ex:
finger Deepak
ftp File transfer program. (ftp <remote system name/ip)
ifconfig Configure a network interface. Ex:
ifconfig eth0 172.31.2.2 netmask 255.255.0.0
ifdown Shutdown a network interface. Ex: ifdown eth0
ifup Brings a network interface up. Ex: ifup eth0
Linux Commands

Network Management Commands

netstat Displays information about the systems network


connections, including port connections, routing tables,
and more. The command "netstar -r" will display the
routing table. (netsat –rn)
nslookup Used to query DNS servers for information
about hosts.
Linux Commands

Network Management Commands

ping Send ICMP ECHO_REQUEST packets to network


hosts. (ping <remote-host-name/ip)
route Show or manipulate the IP routing table. (route,
route add, route del)
ssh Secure Login (ssh <remote system name/ip>)
– Install openssh-client
• Sudo apt-get install openssh-client
– Install openssh-server
• Sudo apt-get install openssh-server
Linux Commands

Network Management Commands

Configuration SSH
sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.original
sudo chmod a-w /etc/ssh/sshd_config.original
Modify sshd_config
PubkeyAuthentication yes
Restart the sshd server application
sudo /etc/init.d/ssh restart
SSH from local machine
Ssh username@remote-machine
Linux Commands

Network Management Commands

SSH Keys: allow authentication between two hosts


without the need of a password
To generate the keys,
ssh-keygen -t dsa

Now copy the id_dsa.pub file to the remote host and


append it to ~/.ssh/authorized_keys
ssh-copy-id username@remotehost
If the permissions are not correct change them by:
chmod 644 .ssh/authorized_keys
Linux Commands

Network Management Commands

tcpdump Dump traffic on a network. Prints out headers of packets


that match the boolean expression.
tcpdump -i eth0
tcpdump port #
Tcpdump is a command line packet sniffer. Packet sniffer is a
computer software that captures the incoming and outgoing
traffic over a network.
telnet User interface to the TELNET protocol, setting up a
remote console session. (telnet <remote system
name/ip>)
traceroute Print the route that packets take to the
specified network host. (traceroute <remote system
name/ip>)
Linux Commands

Network Management Commands

Communications commands (includes mail)


elm Electronic mail.
pine Program for internet news and e-mail, Can send
documents, graphics, local & remote messages.
talk Lets two parties talk simultaneously.
mail To send a mail
Linux Commands

System Management Commands

Runtime level management


exit Terminates the shell.
halt Stop the system.
init Process control initialization. (init 3)
logout Log the user off the system.
poweroff Brings the system down.
reboot Reboot the system.
Linux Commands

System Management Commands

shutdown If your system has many users, use the


command shutdown -h +time ‘<message>`, where time
is the time in minutes until the system is halted, and
message is a short explanation of why the system is
shutting down.
Ex: # shutdown -h +10 'We will install a new disk.
System should be back on-line in three hours.‘
Linux Commands

System Management Commands

passwd Set a user's pass word. (passwd, passwd


<username>)
quota Display users' limits and current disk usage.
(quota, quota <username>)
quotaoff Turns filesystem quotas off.
quotaon Turns filesystem quotas on.
quotacheck Used to check a filesystem for usage, and
update the quota.user file.
edquota Used to edit user or group quotas. (edquota
<username>)
Linux Commands

System Management Commands

su Single user login. (su -)


useradd Create a new user or update default new user
information. (useradd –g <group> -s <shell> -c
<comment> –d <home directory> <username>
userdel Delete a user account and related files.
(userdel <user name>)
usermod Modify a user account.
users Print the user names of users currently logged in.
wall Send a message to everybody's terminal. (wall
“text message”)
who Display the users logged in.
whoami Print effective user id.
Linux Commands

System Management Commands

System Time
cal Calendar. (cal, cal 2005)
date Print or set the system date and time. (date, date
MMDDhhmm[[CC]YY][.ss])
hwclock Set or read the hardware CMOS clock.
uptime Reports how long the system has been running.
Linux Commands

Linux Job & Process Management


Linux Process Management
ps Get the status of one or more processes.
PPID-parent process ID ; PID-process ID
Eg: ps ax |more to see all processes including daemons
Eg : ps –ef | grep <process>
pstree Display the tree of running processes.
pgrep looks through the currently running processes and
lists the process IDs which matches the selection criteria
to stdout.All the criteria have to match.
top The top program provides a dynamic real-time view
of a running system. It can display system summary
information as well as a list of tasks currently being
managed by the Linux kernel
Linux Commands

Linux Job & Process Management


Linux Process Management
gbackground Starts a suspended process in the
background
fg Starts a suspended process in the foreground
kill Ex: "kill 34" - Effect: Kill or stop the process with the
process ID number 34.
killall Kill processes by name. Can check for and restart
processes.

You might also like