Language: EN

comandos-linux-informacion

Linux Commands - System Information and Monitoring

I present to you a compilation of the most useful Linux commands for system information and monitoring


#clear terminal screen (same effect as control+l)
clear


#reset terminal session
reset


#end local or remote terminal (ssh) session and terminate started processes
exit

Resource Management


#show running tasks and their resource usage 
top


#show executable tasks and enhanced resources
htop


#show RAM state in megabytes
free -h

Disk Space


#show a list of mounted partitions
df -h


#show file and directory sizes sorted by size
ls -lSr |more


#Estimate space used by directory 'dir1'
du -sh directory


#show file and directory sizes sorted by size
du -sk * | sort -rn

System Information


#show data of connected users
who -a


#show reboot history
last reboot


#Show Linux and Kernel architecture and version
uname -a


#show loaded kernel.
lsmod


#show system's hardware components.
dmidecode -q


#List hard drive partitions
*cat /etc/fstab


#show hard drive features
hdparm -i /dev/hda


#show PCI devices
lspci


#show USB devices
lsusb


#show kernel loading process events
tail /var/log/dmesg


#show system events
tail /var/log/messages


#show a list of files open by processes
lsof -p $$


#show a list of files open in a given system path
lsof /directory


#show system calls made and received by a process
strace -c ls >/dev/null


#show library calls
strace -f -e open ls >/dev/null


#show real-time interruptions
watch -n1 'cat /proc/interrupts'

System Shutdown and Restart


#logout user session
logout


#shut down system now
shutdown now


#restart system now
shutdown -r now


#scheduled shutdown
shutdown hours:minutes &


#cancel scheduled shutdown
shutdown -c

Dates


#show system date
date


#show a one-year calendar
cal year


#show a calendar for a month and year
cal month year 2011

Help


#online manual of command
man command


#show a descriptive summary of the function of command
whatis command


#search for commands by task performed (inverse of the previous one)
apropos text

Internet File Downloads


#download file from website
wget www.website.com/file 


#download a file with the ability to stop the download and resume later.
wget -c www.website.com/file 


#download entire website
wget -r www.website.com

Network Operations


#show Ethernet configuration
ifconfig eth0


#activate eth0 interface
ifup eth0


#disable eth0 interface
ifdown eth0


#configure an IP address
ifconfig eth0 192.168.1.1 netmask 255.255.255.0


#configure eth0 in common mode for packet capture (sniffing)
ifconfig eth0 promisc


#activate the 'eth0' interface in dhcp mode
dhclient eth0


#show routing table
route -n


#configure default entry
route add -net 0/0 gw IP_Gateway


#configure static route to search the network '192.168.0.0/16'
route add -net 192.168.0.0 netmask 255.255.0.0 gw 192.168.1.1


#delete static route
route del 0/0 gw IP_gateway


#activate ip routing
echo "1" > /proc/sys/net/ipv4/ip_forward


#show hostname
hostname


#look up hostname to resolve name to an IP address
host www.website.com


#look up hostname to resolve name to an IP address and vice versa
nslookup www.website.com


#show link status of all interfaces
ip link show


#show link status of eth0
mii-tool eth0


#show eth0 network card statistics
ethtool eth0


#show all active network connections and their PID
netstat -tup


#show all network listening services on the system and their PID
netstat -tupl


#show all HTTP traffic
tcpdump tcp port 80


#show wireless networks
iwlist scan


#show configuration of a wireless network card
iwconfig wlan0


#search Whois database
whois www.website.com

SSH, SCP and Tunneling


#start ssh session
ssh user@server.domain.com


#start ssh session with X11 compatibility (allows for visual tasks)
ssh -X user@machine 


#start ssh session on a specific port
ssh -p 15000 user@machine 


#copy file using scp
scp /file user@server.domain.com:/directory


#ssh tunnel creation
ssh -f user@server.domain.com -L 2000:server.domain.com:25 -N


#port redirection using tunneling
ssh -v -L4001:localhost:4001 user@server.domain.com

Microsoft Windows Networks (SAMBA)


#bios network name resolution
nbtscan ip_addr


#bios network name resolution
nmblookup -A ip_addr


#show remote actions of a host in windows
smbclient -L ip_addr/hostname

To see the complete compilation of Linux commands follow this link: List of Linux Commands