Linux常用命令大全 Linux Commands Line - v1.0
The most complete and updated list of commands on linux by LinuxGuide.it - over 350 commands!COMMAND DESCRIPTION
System information
arch show architecture of machine
uname -r show used kernel version
dmidecode -q show hardware system components - (SMBIOS / DMI)
hdaparm -i /dev/hda displays the characteristics of a hard-disk
hdparm -tT /dev/sda perform test reading on a hard-disk
cat /proc/cpuinfo show information CPU info
cat /proc/interrupts show interrupts
cat /proc/meminfo verify memory use
cat /proc/swaps show file(s) swap
cat /proc/version show version of the kernel
cat /proc/net/dev show network adpters and statistics
cat /proc/mounts show mounted file system(s)
lspci -tv display PCI devices
lsusb -tv show USB devices
date show system date
cal 2007 show the timetable of 2007
date 041217002007.00 set date and time - MonthDayhoursMinutesYear.Secondi
clock -w
save changes on BIOS
linux commands line v1.0 - LinuxGuide.it
Shutdown, Restart of a system and Logout
shutdown -h now shutdown system
init 0
shutdown -r hours:minutes & planned shutdown of the system
shutdown -c cancel a planned shutdown of the system
shutdown -r now reboot
reboot
logout leaving session
linux commands line v1.0 - LinuxGuide.it
Files and Directory
cd /home enter to directory '/ home'
cd .. go back one level
cd ../.. go back two levels
cd go to home directory
cd ~utente go to home directory
cd - go to previous directory
pwd show the path of work directory
ls view files of directory
ls -F view files of directory
ls -l show details of files and directory
ls -a show hidden files
ls *[0-9]* show files and directory containing numbers
lstree show files and directories in a tree starting from root
mkdir dir1 create a directory called 'dir1'
mkdir dir1 dir2 create two directories simultaneously
mkdir -p /tmp/dir1/dir2 create a directory tree
rm -f file1 delete file called 'file1'
rmdir dir1 delete directory called 'dir1'
rm -rf dir1 remove a directory called 'dir1' and contents recursively
rm -rf dir1 dir2 remove two directories and their contents recursively
mv dir1 new_dir rename / move a file or directory
cp file1 file2 copying a file
cp dir/* . copy all files of a directory within the current work directory
cp -a /tmp/dir1 . copy a directory within the current work directory
cp -a dir1 dir2 copy a directory
ln -s file1 lnk1 create a symbolic link to file or directory
ln file1 lnk1 create a physical link to file or directory
touch -t 0712250000 fileditest modify timestamp of a file or directory - (YYMMDDhhmm)
linux commands line v1.0 - LinuxGuide.it
File search
find / -name file1 search file and directory into root filesystem from '/'
find / -user user1 search files and directories belonging to 'user1'
find /home/user1 -name *.bin search files with '. bin' extension within directory '/ home/user1'
find /usr/bin -type f -atime +100 search bynary files are not used in the last 100 days
find /usr/bin -type f -mtime -10 search files created or changed within 10 days
find / -name *.rpm -exec chmod 755 {} ; search files with '.rpm' extension and modify permits
find / -name *.rpm -xdev search files with '.rpm' extension ignoring removable partitions as cdrom, pen-drive, etc.…
locate *.ps find files with the '.ps' extension - first run 'updatedb' command
whereis halt show location of a binary file, source or man
which halt show full path to a binary / executable
linux commands line v1.0 - LinuxGuide.it
Mounting a Filesystem
mount /dev/hda2 /mnt/hda2 mount disk called hda2 - verify existence of the directory '/ mnt/hda2'
umount /dev/hda2 unmount disk called hda2 - exit from mount point '/ mnt/hda2' first
fuser -km /mnt/hda2 force umount when the device is busy
umount -n /mnt/hda2 run umount without writing the file /etc/mtab - useful when the file is read-only or the hard disk is full
mount /dev/fd0 /mnt/floppy mount a floppy disk
mount /dev/cdrom /mnt/cdrom mount a cdrom / dvdrom
mount /dev/hdc /mnt/cdrecorder mount a cdrw / dvdrom
mount /dev/hdb /mnt/cdrecorder mount a cdrw / dvdrom
mount -o loop file.iso /mnt/cdrom mount a file or iso image
mount -t vfat /dev/hda5 /mnt/hda5 mount a Windows FAT32 file system
mount /dev/sda1 /mnt/usbdisk mount a usb pen-drive or flash-drive
mount -t smbfs -o username=user,password=pass //winclient/share /mnt/share mount a windows network share
linux commands line v1.0 - LinuxGuide.it
Disk Space
df -h show list of partitions mounted
ls -lSr |more show size of the files and directories ordered by size
du -sh dir1 estimate space used by directory 'dir1'
du -sh * | sort -rn show size of the files and directories sorted by size
rpm -q -a --qf '%10{SIZE}\t%{NAME}\n' | sort -k1,1n show space used by rpm packages installed sorted by size (fedora, redhat and like)
dpkg-query -W -f='${Installed-Size;10}\t${Package}\n' | sort -k1,1n show space used by deb packages installed sorted by size (ubuntu, debian and like)
linux commands line v1.0 - LinuxGuide.it
Users and Groups
groupadd group_name create a new group
groupdel group_name delete a group
groupmod -n new_group_name old_group_name rename a group
useradd -c "Nome Cognome" -g admin -d /home/user1 -s /bin/bash user1 create a new user belongs "admin" group
useradd user1 create a new user
userdel -r user1 delete a user ( '-r' eliminates home directory)
usermod -c "User FTP" -g system -d /ftp/user1 -s /bin/nologin user1 change user attributes
passwd change password
passwd user1 change a user password (only by root)
chage -E 2005-12-31 user1 set deadline for user password
pwck check correct syntax and file format of '/etc/passwd' and users existence
grpck check correct syntax and file format of '/etc/group' and groups existence
newgrp group_name log in to a new group to change default group of newly created files
linux commands line v1.0 - LinuxGuide.it
Permits on File - use "+" to set permissions and "-" to remove
ls -lh show permits
ls /tmp | pr -T5 -W$COLUMNS divide terminal into 5 columns
chmod ugo+rwx directory1 set permissions reading (r), write (w) and (x) access to users owner (u) group (g) and others (o)
chmod go-rwx directory1 remove permits reading (r), write (w) and (x) access to users group (g) and others (or
chown user1 file1 change owner of a file
chown user1 -R directory1 change user owner of a directory and all the files and directories contained inside
chgrp gruppo1 file1 change group of files
chown user1:gruppo1 file1 change user and group ownership of a file
find / -perm -u+s view all files on the system with SUID configured
chmod u+s /bin/file_eseguibile set SUID bit on a binary file - the user that running that file gets same privileges as owner
chmod u-s /bin/file_binario disable SUID bit on a binary file
chmod g+s /home/public set SGID bit on a directory - similar to SUID but for directory
chmod g-s /home/public disable SGID bit on a directory
chmod o+t /home/comune set STIKY bit on a directory - allows files deletion only to legitimate owners
chmod o-t /home/comune disable STIKY bit on a directory
linux commands line v1.0 - LinuxGuide.it
Special Attributes on file - use "+" to set permissions and "-" to remove
chattr +a file1 allows write opening of a file only append mode
chattr +c file1 allows that a file is compressed / decompressed automatically by the kernel
chattr +d file1 makes sure that the program ignores Dump the files during backup
chattr +i file1 makes it an immutable file, which can not be removed, altered, renamed or linked
chattr +s file1 allows a file to be deleted safely
chattr +S file1 makes sure that if a file is modified changes are written in synchronous mode as with sync
chattr +u file1 allows you to recover the contents of a file even if it is canceled
lsattr show specials attributes
linux commands line v1.0 - LinuxGuide.it
Archives and compressed files
bunzip2 file1.bz2 decompress a file called 'file1.bz2'
bzip2 file1 compress a file called 'file1'
gunzip file1.gz decompress a file called 'file1.gz'
gzip file1 compress a file called 'file1'
gzip -9 file1 compress with maximum compression
rar a file1.rar test_file create an archive rar called 'file1.rar'
rar a file1.rar file1 file2 dir1 compress 'file1', 'file2' and 'dir1' simultaneously
rar x file1.rar decompress rar archive
unrar x file1.rar decompress rar archive
tar -cvf archive.tar file1 create a uncompressed tarball
tar -cvf archive.tar file1 file2 dir1 create an archive containing 'file1', 'file2' and 'dir1'
tar -tf archive.tar show contents of an archive
tar -xvf archive.tar extract a tarball
tar -xvf archive.tar -C /tmp extract a tarball into / tmp
tar -cvfj archive.tar.bz2 dir1 create a tarball compressed into bzip2
tar -xvfj archive.tar.bz2 decompress a compressed tar archive in bzip2
tar -cvfz archive.tar.gz dir1 create a tarball compressed into gzip
tar -xvfz archive.tar.gz decompress a compressed tar archive in gzip
zip file1.zip file1 create an archive compressed in zip
zip -r file1.zip file1 file2 dir1 compress in zip several files and directories simultaneously
unzip file1.zip decompress a zip archive
linux commands line v1.0 - LinuxGuide.it
RPM Packages - Fedora, Red Hat and like
rpm -ivh package.rpm install a rpm package
rpm -ivh --nodeeps package.rpm install a rpm package ignoring dependencies requests
rpm -U package.rpm upgrade a rpm package without changing configuration files
rpm -F package.rpm upgrade a rpm package only if it is already installed
rpm -e package_name.rpm remove a rpm package
rpm -qa show all rpm packages installed on the system
rpm -qa | grep httpd show all rpm packages with the name "httpd"
rpm -qi package_name obtain information on a specific package installed
rpm -qg "System Environment/Daemons" show rpm packages of a group software
rpm -ql package_name show list of files provided by a rpm package installed
rpm -qc package_name show list of configuration files provided by a rpm package installed
rpm -q package_name --whatrequires show list of dependencies required for a rpm packet
rpm -q package_name --whatprovides show capability provided by a rpm package
rpm -q package_name --scripts show scripts started during installation / removal
rpm -q package_name --changelog show history of revisions of a rpm package
rpm -qf /etc/httpd/conf/httpd.conf verify which rpm package belongs to a given file
rpm -qp package.rpm -l show list of files provided by a rpm package not yet installed
rpm --import /media/cdrom/RPM-GPG-KEY import public-key digital signature
rpm --checksig package.rpm verify the integrity of a rpm package
rpm -qa gpg-pubkey verify integrity of all rpm packages installed
rpm -V package_name check file size, permissions, type, owner, group, MD5 checksum and last modification
rpm -Va check all rpm packages installed on the system - use with caution
rpm -Vp package.rpm verify a rpm package not yet installed
rpm2cpio package.rpm | cpio --extract --make-directories *bin* extract executable file from a rpm package
rpm -ivh /usr/src/redhat/RPMS/`arch`/package.rpm install a package built from a rpm source
rpmbuild --rebuild package_name.src.rpm build a rpm package from a rpm source
linux commands line v1.0 - LinuxGuide.it
YUM packages updater - Fedora, RedHat and like
yum install package_name download and install a rpm package
yum update update all rpm packages installed on the system
yum update package_name upgrade a rpm package
yum remove package_name remove a rpm package
yum list list all packages installed on the system
yum search package_name find a package on rpm repository
yum clean packages clean up rpm cache erasing downloaded packages
yum clean headers remove all files headers that the system uses to resolve dependency
yum clean all remove from the cache packages and headers files
linux commands line v1.0 - LinuxGuide.it
DEB packages - Debian, Ubuntu and like
dpkg -i package.deb install / upgrade a deb package
dpkg -r package_name remove a deb package from the system
dpkg -l show all deb packages installed on the system
dpkg -l | grep httpd show all rpm packages with the name "httpd"
dpkg -s package_name obtain information on a specific package installed on system
dpkg -L package_name show list of files provided by a package installed on system
dpkg --contents package.deb show list of files provided by a package not yet installed
dpkg -S /bin/ping verify which package belongs to a given file
linux commands line v1.0 - LinuxGuide.it
APT packages updater - Debian, Ubuntu e like
apt-get install package_name install / upgrade a deb package
apt-cdrom install package_name install / upgrade a deb package from cdrom
apt-get update update all deb packages installed on system
apt-get remove package_name remove a deb package from system
apt-get check verify correct resolution of dependencies
apt-get clean clean up cache from packages downloaded
linux commands line v1.0 - LinuxGuide.it
View file content
cat file1 view the contents of a file starting from the first row
tac file1 view the contents of a file starting from the last line
more file1 view content of a file along
less file1 similar to 'more' command but which allows backward movement in the file as well as forward movement
head -2 file1 view first two lines of a file
tail -2 file1 view last two lines of a file
tail -f /var/log/messages view in real time what is added to a file
linux commands line v1.0 - LinuxGuide.it
Text Manipulation
cat file_test | [operation: sed, grep, awk, grep, etc] > result.txt syntax to elaborate the text of a file, and write result to a new file
cat file_originale | [operazione: sed, grep, awk, grep, etc] >> result.txt syntax to elaborate the text of a file and append result in existing file
grep Aug /var/log/messages look up words "Aug" on file '/var/log/messages'
grep ^Aug /var/log/messages look up words that begin with "Aug" on file '/var/log/messages'
grep [0-9] /var/log/messages select from file '/var/log/messages' all lines that contain numbers
grep Aug -R /var/log/* search string "Aug" at directory '/var/log' and below
grep Aug /var/log/messages write result of a search within a file
sed 's/stringa1/stringa2/g' example.txt replace "string1" with "string2" in example.txt
sed '/^$/d' example.txt remove all blank lines from example.txt
sed '/ *#/d; /^ *$/d' example.txt remove comments and blank lines from example.txt
echo 'esempio' | tr '[:lower:]' '[:upper:]' convert from lower case in upper case
sed -e '1d' result.txt eliminates the first line from file example.txt
sed -n '/stringa1/p' view only lines that contain the word "string1"
sed -e 's/ *$//' example.txt remove empty characters at the end of each row
sed -e 's/stringa1//g' example.txt remove only the word "string1" from text and leave intact all
sed -n '1,5p;5q' example.txt view from 1th to 5th row
sed -n '5p;5q' example.txt view row number 5
sed -e 's/00*/0/g' example.txt replace more zeros with a single zero
cat -n file1 number row of a file
cat example.txt | awk 'NR%2==1' remove all even lines from example.txt
echo a b c | awk '{print $1}' view the first column of a line
echo a b c | awk '{print $1,$3}' view the first and third column of a line
paste file1 file2 merging contents of two files for columns
paste -d '+' file1 file2 merging contents of two files for columns with '+' delimiter on the center
sort file1 file2 sort contents of two files
sort file1 file2 | uniq sort contents of two files omitting lines repeated
sort file1 file2 | uniq -u sort contents of two files by viewing only unique line
sort file1 file2 | uniq -d sort contents of two files by viewing only duplicate line
comm -1 file1 file2 compare contents of two files by deleting only unique lines from 'file1'
comm -2 file1 file2 compare contents of two files by deleting only unique lines from 'file2'
comm -3 file1 file2 compare contents of two files by deleting only the lines that appear on both files
linux commands line v1.0 - LinuxGuide.it
Character set and Format file conversion
dos2unix filedos.txt fileunix.txt convert a text file format from MSDOS to UNIX
unix2dos fileunix.txt filedos.txt convert a text file format from UNIX to MSDOS
recode ..HTML page.html convert a text file to html
recode -l | more show all available formats conversion
linux commands line v1.0 - LinuxGuide.it
Filesystem Analysis
badblocks -v /dev/hda1 check bad blocks in disk hda1
fsck /dev/hda1 repair / check integrity of linux filesystem on disk hda1
fsck.ext2 /dev/hda1 repair / check integrity of ext2 filesystem on disk hda1
e2fsck /dev/hda1 repair / check integrity of ext2 filesystem on disk hda1
e2fsck -j /dev/hda1 repair / check integrity of ext3 filesystem on disk hda1
fsck.ext3 /dev/hda1 repair / check integrity of ext3 filesystem on disk hda1
fsck.vfat /dev/hda1 repair / check integrity of fat filesystem on disk hda1
fsck.msdos /dev/hda1 repair / check integrity of dos filesystem on disk hda1
dosfsck /dev/hda1 repair / check integrity of dos filesystems on disk hda1
linux commands line v1.0 - LinuxGuide.it
Format a Filesystem
mkfs /dev/hda1 create a filesystem type linux on hda1 partition
mke2fs /dev/hda1 create a filesystem type linux ext2 on hda1 partition
mke2fs -j /dev/hda1 create a filesystem type linux ext3 (journal) on hda1 partition
mkfs -t vfat 32 -F /dev/hda1 create a FAT32 filesystem
fdformat -n /dev/fd0 format a floppy disk
mkswap /dev/hda3 create a swap filesystem
linux commands line v1.0 - LinuxGuide.it
SWAP filesystem
mkswap /dev/hda3 create a swap filesystem
swapon /dev/hda3 activating a new swap partition
swapon /dev/hda2 /dev/hdb3 activate two swap partitions
linux commands line v1.0 - LinuxGuide.it
Backup
dump -0aj -f /tmp/home0.bak /home make a full backup of directory '/home'
dump -1aj -f /tmp/home0.bak /home make a incremental backup of directory '/home'
restore -if /tmp/home0.bak restoring a backup interactively
rsync -rogpav --delete /home /tmp synchronization between directories
rsync -rogpav -e ssh --delete /home ip_address:/tmp rsync via SSH tunnel
rsync -az -e ssh --delete ip_addr:/home/public /home/local synchronize a local directory with a remote directory via ssh and compression
rsync -az -e ssh --delete /home/local ip_addr:/home/public synchronize a remote directory with a local directory via ssh and compression
dd bs=1M if=/dev/hda | gzip | ssh
[email=user@ip_addr]user@ip_addr[/email]
'dd of=hda.gz' make a backup of a local hard disk on remote host via ssh
tar -Puf backup.tar /home/user make a incremental backup of directory '/home/user'
( cd /tmp/local/ && tar c . ) | ssh -C
[email=user@ip_addr]user@ip_addr[/email]
'cd /home/share/ && tar x -p' copy content of a directory on remote directory via ssh
( tar c /home ) | ssh -C
[email=user@ip_addr]user@ip_addr[/email]
'cd /home/backup-home && tar x -p' copy a local directory on remote directory via ssh
tar cf - . | (cd /tmp/backup ; tar xf - ) local copy preserving permits and links from a directory to another
find /home/user1 -name '*.txt' | xargs cp -av --target-directory=/home/backup/ --parents find and copy all files with '.txt' extention from a directory to another
find /var/log -name '*.log' | tar cv --files-from=- | bzip2 > log.tar.bz2 find all files with '.log' extention and make an bzip archive
dd if=/dev/hda of=/dev/fd0 bs=512 count=1 make a copy of MBR (Master Boot Record) to floppy
dd if=/dev/fd0 of=/dev/hda bs=512 count=1 restore MBR from backup copy saved to floppy
linux commands line v1.0 - LinuxGuide.it
CDROM
cdrecord -v gracetime=2 dev=/dev/cdrom -eject blank=fast -force clean a rewritable cdrom
mkisofs /dev/cdrom > cd.iso create an iso image of cdrom on disk
mkisofs /dev/cdrom | gzip > cd_iso.gz create a compressed iso image of cdrom on disk
mkisofs -J -allow-leading-dots -R -V "Label CD" -iso-level 4 -o ./cd.iso data_cd create an iso image of a directory
cdrecord -v dev=/dev/cdrom cd.iso burn an ISO image
gzip -dc cd_iso.gz | cdrecord dev=/dev/cdrom - burn a compressed ISO image
mount -o loop cd.iso /mnt/iso mount an ISO image
cd-paranoia -B rip audio tracks from a CD to wav files
cd-paranoia -- "-3" rip first three audio tracks from a CD to wav files
cdrecord --scanbus scan bus to identify the channel scsi
linux commands line v1.0 - LinuxGuide.it
Networking - LAN and WiFi
ifconfig eth0 show configuration of an ethernet network card
ifup eth0 activate an interface 'eth0'
ifdown eth0 disable an interface 'eth0'
ifconfig eth0 192.168.1.1 netmask 255.255.255.0 configure IP Address
ifconfig eth0 promisc configure 'eth0' in promiscuous mode to gather packets (sniffing)
dhclient eth0 active interface 'eth0' in dhcp mode
route -n show routing table
route add -net 0/0 gw IP_Gateway configura default gateway
route add -net 192.168.0.0 netmask 255.255.0.0 gw 192.168.1.1 configure static route to reach network '192.168.0.0/16'
route del 0/0 gw IP_gateway remove static route
echo "1" > /proc/sys/net/ipv4/ip_forward activate ip routing
hostname show hostname
host
www.linuxguide.it
lookup hostname to resolve name to ip address and viceversa
ip link show show link status of all interfaces
mii-tool eth0 show link status of 'eth0'
ethtool eth0 show statistics of network card 'eth0'
netstat -tup show all active network connections and their PID
netstat -tupl show all network services listening on the system and their PID
tcpdump tcp port 80 show all HTTP traffic
iwlist scan show wireless networks
iwconfig eth1 show configuration of a wireless network card
linux commands line v1.0 - LinuxGuide.it
Microsoft Windows networks - SAMBA
nbtscan ip_addr netbios name resolution
nmblookup -A ip_addr netbios name resolution
smbclient -L ip_addr/hostname show remote shares of a windows host
smbget -Rr smb://ip_addr/share like wget can download files from a host windows via smb
mount -t smbfs -o username=user,password=pass //winclient/share /mnt/share mount a windows network share
linux commands line v1.0 - LinuxGuide.it
IPTABLES - firewall
iptables -t filter -L show all chains of filtering table
iptables -t nat -L show all chains of nat table
iptables -t filter -F clear all rules from filtering table
iptables -t nat -F clear all rules from table nat
iptables -t filter -X delete any chains created by user
iptables -t filter -A INPUT -p tcp --dport telnet -j ACCEPT allow telnet connections to input
iptables -t filter -A OUTPUT -p tcp --dport http -j DROP block HTTP connections to output
iptables -t filter -A FORWARD -p tcp --dport pop3 -j ACCEPT allow POP3 connections to forward chain
iptables -t filter -A INPUT -j LOG --log-prefix "DROP INPUT" logging sulla chain di input Logging on chain input
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE configure a PAT (Port Address Traslation) on eth0 masking outbound packets
iptables -t nat -A PREROUTING -d 192.168.0.1 -p tcp -m tcp --dport 22 -j DNAT --to-destination 10.0.0.2:22 redirect packets addressed to a host to another host
linux commands line v1.0 - LinuxGuide.it
Monitoring and debugging
top display linux tasks using most cpu
ps -eafw displays linux tasks
ps -e -o pid,args --forest displays linux tasks in a hierarchical mode
pstree mostra un albero dei processi sistema Shows a tree system processes
kill -9 ID_Processo force closure of the process and finish it
kill -1 ID_Processo force a process to reload configuration
lsof -p $$ display a list of files opened by processes
lsof /home/user1 displays a list of open files in a given path system
strace -c ls >/dev/null display system calls made and received by a process
strace -f -e open ls >/dev/null display library calls
watch -n1 'cat /proc/interrupts' display interrupts in real-time
last reboot show history reboot
lsmod display kernel loaded
free -m displays status of RAM in megabytes
smartctl -A /dev/hda monitoring reliability of a hard-disk through SMART
smartctl -i /dev/hda check if SMART is active on a hard-disk
tail /var/log/dmesg show events inherent to the process of booting kernel
tail /var/log/messages show system events
linux commands line v1.0 - LinuxGuide.it
Other useful commands
mkbootdisk --device /dev/fd0 `uname -r` create a boot floppy
gpg -c file1 encrypt a file with GNU Privacy Guard
gpg file1.gpg decrypt a file with GNU Privacy Guard
wget -r
www.example.com
download an entire web site
wget -c
www.example.com/file.iso
download a file with the ability to stop the download and resume later
echo 'wget -c
[url=https://www.example.com/files.iso']www.example.com/files.iso'[/url]
| at 09:00 start a download at any given time
ldd ssh show shared libraries required by ssh program
alias hh='history' set an alias for a command - hh = history
---------------------------------
係統信息 arch 顯示機器的處理器架構(1) uname -m 顯示機器的處理器架構(2) uname -r 顯示正在使用的內核版本 dmidecode -q 顯示硬件係統部件 - (SMBIOS / DMI) hdparm -i /dev/hda 羅列一個磁盤的架構特性 hdparm -tT /dev/sda 在磁盤上執行測試性讀取操作
係統信息
arch 顯示機器的處理器架構(1)
uname -m 顯示機器的處理器架構(2)
uname -r 顯示正在使用的內核版本
dmidecode -q 顯示硬件係統部件 - (SMBIOS / DMI)
hdparm -i /dev/hda 羅列一個磁盤的架構特性
hdparm -tT /dev/sda 在磁盤上執行測試性讀取操作
cat /proc/cpuinfo 顯示CPU info的信息
cat /proc/interrupts 顯示中斷
cat /proc/meminfo 校驗內存使用
cat /proc/swaps 顯示哪些swap被使用
cat /proc/version 顯示內核的版本
cat /proc/net/dev 顯示網絡適配器及統計
cat /proc/mounts 顯示已加載的文件係統
lspci -tv 羅列 PCI 設備
lsusb -tv 顯示 USB 設備
date 顯示係統日期
cal 2007 顯示2007年的日曆表
date 041217002007.00 設置日期和時間 - 月日時分年.秒
clock -w 將時間修改保存到 BIOS
關機 (係統的關機、重啟以及登出 )
shutdown -h now 關閉係統(1)
init 0 關閉係統(2)
telinit 0 關閉係統(3)
shutdown -h hours:minutes & 按預定時間關閉係統
shutdown -c 取消按預定時間關閉係統
shutdown -r now 重啟(1)
reboot 重啟(2)
logout 注銷
文件和目錄
cd /home 進入 '/ home' 目錄'
cd .. 返回上一級目錄
cd ../.. 返回上兩級目錄
cd 進入個人的主目錄
cd ~user1 進入個人的主目錄
cd - 返回上次所在的目錄
pwd 顯示工作路徑
ls 查看目錄中的文件
ls -F 查看目錄中的文件
ls -l 顯示文件和目錄的詳細資料
ls -a 顯示隱藏文件
ls *[0-9]* 顯示包含數字的文件名和目錄名
tree 顯示文件和目錄由根目錄開始的樹形結構(1)
lstree 顯示文件和目錄由根目錄開始的樹形結構(2)
mkdir dir1 創建一個叫做 'dir1' 的目錄'
mkdir dir1 dir2 同時創建兩個目錄
mkdir -p /tmp/dir1/dir2 創建一個目錄樹
rm -f file1 刪除一個叫做 'file1' 的文件'
rmdir dir1 刪除一個叫做 'dir1' 的目錄'
rm -rf dir1 刪除一個叫做 'dir1' 的目錄並同時刪除其內容
rm -rf dir1 dir2 同時刪除兩個目錄及它們的內容
mv dir1 new_dir 重命名/移動 一個目錄
cp file1 file2 複製一個文件
cp dir/* . 複製一個目錄下的所有文件到當前工作目錄
cp -a /tmp/dir1 . 複製一個目錄到當前工作目錄
cp -a dir1 dir2 複製一個目錄
ln -s file1 lnk1 創建一個指向文件或目錄的軟鏈接
ln file1 lnk1 創建一個指向文件或目錄的物理鏈接
touch -t 0712250000 file1 修改一個文件或目錄的時間戳 - (YYMMDDhhmm)
file file1 outputs the mime type of the file as text
iconv -l 列出已知的編碼
iconv -f fromEncoding -t toEncoding inputFile > outputFile creates a new from the given input file by assuming it is encoded in fromEncoding and converting it to toEncoding.
find . -maxdepth 1 -name *.jpg -print -exec convert "{}" -resize 80x60 "thumbs/{}" \; batch resize files in the current directory and send them to a thumbnails directory (requires convert from Imagemagick)
文件搜索
find / -name file1 從 '/' 開始進入根文件係統搜索文件和目錄
find / -user user1 搜索屬於用戶 'user1' 的文件和目錄
find /home/user1 -name \*.bin 在目錄 '/ home/user1' 中搜索帶有'.bin' 結尾的文件
find /usr/bin -type f -atime +100 搜索在過去100天內未被使用過的執行文件
find /usr/bin -type f -mtime -10 搜索在10天內被創建或者修改過的文件
find / -name \*.rpm -exec chmod 755 '{}' \; 搜索以 '.rpm' 結尾的文件並定義其權限
find / -xdev -name \*.rpm 搜索以 '.rpm' 結尾的文件,忽略光驅、捷盤等可移動設備
locate \*.ps 尋找以 '.ps' 結尾的文件 - 先運行 'updatedb' 命令
whereis halt 顯示一個二進製文件、源碼或man的位置
which halt 顯示一個二進製文件或可執行文件的完整路徑
掛載一個文件係統
mount /dev/hda2 /mnt/hda2 掛載一個叫做hda2的盤 - 確定目錄 '/ mnt/hda2' 已經存在
umount /dev/hda2 卸載一個叫做hda2的盤 - 先從掛載點 '/ mnt/hda2' 退出
fuser -km /mnt/hda2 當設備繁忙時強製卸載
umount -n /mnt/hda2 運行卸載操作而不寫入 /etc/mtab 文件- 當文件為隻讀或當磁盤寫滿時非常有用
mount /dev/fd0 /mnt/floppy 掛載一個軟盤
mount /dev/cdrom /mnt/cdrom 掛載一個cdrom或dvdrom
mount /dev/hdc /mnt/cdrecorder 掛載一個cdrw或dvdrom
mount /dev/hdb /mnt/cdrecorder 掛載一個cdrw或dvdrom
mount -o loop file.iso /mnt/cdrom 掛載一個文件或ISO鏡像文件
mount -t vfat /dev/hda5 /mnt/hda5 掛載一個Windows FAT32文件係統
mount /dev/sda1 /mnt/usbdisk 掛載一個usb 捷盤或閃存設備
mount -t smbfs -o username=user,password=pass //WinClient/share /mnt/share 掛載一個windows網絡共享
磁盤空間
df -h 顯示已經掛載的分區列表
ls -lSr |more 以尺寸大小排列文件和目錄
du -sh dir1 估算目錄 'dir1' 已經使用的磁盤空間'
du -sk * | sort -rn 以容量大小為依據依次顯示文件和目錄的大小
rpm -q -a --qf '%10{SIZE}t%{NAME}n' | sort -k1,1n 以大小為依據依次顯示已安裝的rpm包所使用的空間 (fedora, redhat類係統)
dpkg-query -W -f='${Installed-Size;10}t${Package}n' | sort -k1,1n 以大小為依據顯示已安裝的deb包所使用的空間 (ubuntu, debian類係統)
返回頂部索引 ^
用戶和群組
groupadd group_name 創建一個新用戶組
groupdel group_name 刪除一個用戶組
groupmod -n new_group_name old_group_name 重命名一個用戶組
useradd -c "Name Surname " -g admin -d /home/user1 -s /bin/bash user1 創建一個屬於 "admin" 用戶組的用戶
useradd user1 創建一個新用戶
userdel -r user1 刪除一個用戶 ( '-r' 排除主目錄)
usermod -c "User FTP" -g system -d /ftp/user1 -s /bin/nologin user1 修改用戶屬性
passwd 修改口令
passwd user1 修改一個用戶的口令 (隻允許root執行)
chage -E 2005-12-31 user1 設置用戶口令的失效期限
pwck 檢查 '/etc/passwd' 的文件格式和語法修正以及存在的用戶
grpck 檢查 '/etc/passwd' 的文件格式和語法修正以及存在的群組
newgrp group_name 登陸進一個新的群組以改變新創建文件的預設群組
返回頂部索引 ^
文件的權限 - 使用 "+" 設置權限,使用 "-" 用於取消
ls -lh 顯示權限
ls /tmp | pr -T5 -W$COLUMNS 將終端劃分成5欄顯示
chmod ugo+rwx directory1 設置目錄的所有人(u)、群組(g)以及其他人(o)以讀(r )、寫(w)和執行(x)的權限
chmod go-rwx directory1 刪除群組(g)與其他人(o)對目錄的讀寫執行權限
chown user1 file1 改變一個文件的所有人屬性
chown -R user1 directory1 改變一個目錄的所有人屬性並同時改變改目錄下所有文件的屬性
chgrp group1 file1 改變文件的群組
chown user1:group1 file1 改變一個文件的所有人和群組屬性
find / -perm -u+s 羅列一個係統中所有使用了SUID控製的文件
chmod u+s /bin/file1 設置一個二進製文件的 SUID 位 - 運行該文件的用戶也被賦予和所有者同樣的權限
chmod u-s /bin/file1 禁用一個二進製文件的 SUID位
chmod g+s /home/public 設置一個目錄的SGID 位 - 類似SUID ,不過這是針對目錄的
chmod g-s /home/public 禁用一個目錄的 SGID 位
chmod o+t /home/public 設置一個文件的 STIKY 位 - 隻允許合法所有人刪除文件
chmod o-t /home/public 禁用一個目錄的 STIKY 位
返回頂部索引 ^
文件的特殊屬性 - 使用 "+" 設置權限,使用 "-" 用於取消
chattr +a file1 隻允許以追加方式讀寫文件
chattr +c file1 允許這個文件能被內核自動壓縮/解壓
chattr +d file1 在進行文件係統備份時,dump程序將忽略這個文件
chattr +i file1 設置成不可變的文件,不能被刪除、修改、重命名或者鏈接
chattr +s file1 允許一個文件被安全地刪除
chattr +S file1 一旦應用程序對這個文件執行了寫操作,使係統立刻把修改的結果寫到磁盤
chattr +u file1 若文件被刪除,係統會允許你在以後恢複這個被刪除的文件
lsattr 顯示特殊的屬性
返回頂部索引 ^
打包和壓縮文件
bunzip2 file1.bz2 解壓一個叫做 'file1.bz2'的文件
bzip2 file1 壓縮一個叫做 'file1' 的文件
gunzip file1.gz 解壓一個叫做 'file1.gz'的文件
gzip file1 壓縮一個叫做 'file1'的文件
gzip -9 file1 最大程度壓縮
rar a file1.rar test_file 創建一個叫做 'file1.rar' 的包
rar a file1.rar file1 file2 dir1 同時壓縮 'file1', 'file2' 以及目錄 'dir1'
rar x file1.rar 解壓rar包
unrar x file1.rar 解壓rar包
tar -cvf archive.tar file1 創建一個非壓縮的 tarball
tar -cvf archive.tar file1 file2 dir1 創建一個包含了 'file1', 'file2' 以及 'dir1'的檔案文件
tar -tf archive.tar 顯示一個包中的內容
tar -xvf archive.tar 釋放一個包
tar -xvf archive.tar -C /tmp 將壓縮包釋放到 /tmp目錄下
tar -cvfj archive.tar.bz2 dir1 創建一個bzip2格式的壓縮包
tar -xvfj archive.tar.bz2 解壓一個bzip2格式的壓縮包
tar -cvfz archive.tar.gz dir1 創建一個gzip格式的壓縮包
tar -xvfz archive.tar.gz 解壓一個gzip格式的壓縮包
zip file1.zip file1 創建一個zip格式的壓縮包
zip -r file1.zip file1 file2 dir1 將幾個文件和目錄同時壓縮成一個zip格式的壓縮包
unzip file1.zip 解壓一個zip格式壓縮包
返回頂部索引 ^
RPM 包 - (Fedora, Redhat及類似係統)
rpm -ivh package.rpm 安裝一個rpm包
rpm -ivh --nodeeps package.rpm 安裝一個rpm包而忽略依賴關係警告
rpm -U package.rpm 更新一個rpm包但不改變其配置文件
rpm -F package.rpm 更新一個確定已經安裝的rpm包
rpm -e package_name.rpm 刪除一個rpm包
rpm -qa 顯示係統中所有已經安裝的rpm包
rpm -qa | grep httpd 顯示所有名稱中包含 "httpd" 字樣的rpm包
rpm -qi package_name 獲取一個已安裝包的特殊信息
rpm -qg "System Environment/Daemons" 顯示一個組件的rpm包
rpm -ql package_name 顯示一個已經安裝的rpm包提供的文件列表
rpm -qc package_name 顯示一個已經安裝的rpm包提供的配置文件列表
rpm -q package_name --whatrequires 顯示與一個rpm包存在依賴關係的列表
rpm -q package_name --whatprovides 顯示一個rpm包所占的體積
rpm -q package_name --scripts 顯示在安裝/刪除期間所執行的腳本l
rpm -q package_name --changelog 顯示一個rpm包的修改曆史
rpm -qf /etc/httpd/conf/httpd.conf 確認所給的文件由哪個rpm包所提供
rpm -qp package.rpm -l 顯示由一個尚未安裝的rpm包提供的文件列表
rpm --import /media/cdrom/RPM-GPG-KEY 導入公鑰數字證書
rpm --checksig package.rpm 確認一個rpm包的完整性
rpm -qa gpg-pubkey 確認已安裝的所有rpm包的完整性
rpm -V package_name 檢查文件尺寸、 許可、類型、所有者、群組、MD5檢查以及最後修改時間
rpm -Va 檢查係統中所有已安裝的rpm包- 小心使用
rpm -Vp package.rpm 確認一個rpm包還未安裝
rpm2cpio package.rpm | cpio --extract --make-directories *bin* 從一個rpm包運行可執行文件
rpm -ivh /usr/src/redhat/RPMS/`arch`/package.rpm 從一個rpm源碼安裝一個構建好的包
rpmbuild --rebuild package_name.src.rpm 從一個rpm源碼構建一個 rpm 包
返回頂部索引 ^
YUM 軟件包升級器 - (Fedora, RedHat及類似係統)
yum install package_name 下載並安裝一個rpm包
yum localinstall package_name.rpm 將安裝一個rpm包,使用你自己的軟件倉庫為你解決所有依賴關係
yum update package_name.rpm 更新當前係統中所有安裝的rpm包
yum update package_name 更新一個rpm包
yum remove package_name 刪除一個rpm包
yum list 列出當前係統中安裝的所有包
yum search package_name 在rpm倉庫中搜尋軟件包
yum clean packages 清理rpm緩存刪除下載的包
yum clean headers 刪除所有頭文件
yum clean all 刪除所有緩存的包和頭文件
返回頂部索引 ^
DEB 包 (Debian, Ubuntu 以及類似係統)
dpkg -i package.deb 安裝/更新一個 deb 包
dpkg -r package_name 從係統刪除一個 deb 包
dpkg -l 顯示係統中所有已經安裝的 deb 包
dpkg -l | grep httpd 顯示所有名稱中包含 "httpd" 字樣的deb包
dpkg -s package_name 獲得已經安裝在係統中一個特殊包的信息
dpkg -L package_name 顯示係統中已經安裝的一個deb包所提供的文件列表
dpkg --contents package.deb 顯示尚未安裝的一個包所提供的文件列表
dpkg -S /bin/ping 確認所給的文件由哪個deb包提供
返回頂部索引 ^
APT 軟件工具 (Debian, Ubuntu 以及類似係統)
apt-get install package_name 安裝/更新一個 deb 包
apt-cdrom install package_name 從光盤安裝/更新一個 deb 包
apt-get update 升級列表中的軟件包
apt-get upgrade 升級所有已安裝的軟件
apt-get remove package_name 從係統刪除一個deb包
apt-get check 確認依賴的軟件倉庫正確
apt-get clean 從下載的軟件包中清理緩存
apt-cache search searched-package 返回包含所要搜索字符串的軟件包名稱
返回頂部索引 ^
查看文件內容
cat file1 從第一個字節開始正向查看文件的內容
tac file1 從最後一行開始反向查看一個文件的內容
more file1 查看一個長文件的內容
less file1 類似於 'more' 命令,但是它允許在文件中和正向操作一樣的反向操作
head -2 file1 查看一個文件的前兩行
tail -2 file1 查看一個文件的最後兩行
tail -f /var/log/messages 實時查看被添加到一個文件中的內容
返回頂部索引 ^
文本處理
cat file1 file2 ... | command <> file1_in.txt_or_file1_out.txt general syntax for text manipulation using PIPE, STDIN and STDOUT
cat file1 | command( sed, grep, awk, grep, etc...) > result.txt 合並一個文件的詳細說明文本,並將簡介寫入一個新文件中
cat file1 | command( sed, grep, awk, grep, etc...) >> result.txt 合並一個文件的詳細說明文本,並將簡介寫入一個已有的文件中
grep Aug /var/log/messages 在文件 '/var/log/messages'中查找關鍵詞"Aug"
grep ^Aug /var/log/messages 在文件 '/var/log/messages'中查找以"Aug"開始的詞匯
grep [0-9] /var/log/messages 選擇 '/var/log/messages' 文件中所有包含數字的行
grep Aug -R /var/log/* 在目錄 '/var/log' 及隨後的目錄中搜索字符串"Aug"
sed 's/stringa1/stringa2/g' example.txt 將example.txt文件中的 "string1" 替換成 "string2"
sed '/^$/d' example.txt 從example.txt文件中刪除所有空白行
sed '/ *#/d; /^$/d' example.txt 從example.txt文件中刪除所有注釋和空白行
echo 'esempio' | tr '[:lower:]' '[:upper:]' 合並上下單元格內容
sed -e '1d' result.txt 從文件example.txt 中排除第一行
sed -n '/stringa1/p' 查看隻包含詞匯 "string1"的行
sed -e 's/ *$//' example.txt 刪除每一行最後的空白字符
sed -e 's/stringa1//g' example.txt 從文檔中隻刪除詞匯 "string1" 並保留剩餘全部
sed -n '1,5p;5q' example.txt 查看從第一行到第5行內容
sed -n '5p;5q' example.txt 查看第5行
sed -e 's/00*/0/g' example.txt 用單個零替換多個零
cat -n file1 標示文件的行數
cat example.txt | awk 'NR%2==1' 刪除example.txt文件中的所有偶數行
echo a b c | awk '{print $1}' 查看一行第一欄
echo a b c | awk '{print $1,$3}' 查看一行的第一和第三欄
paste file1 file2 合並兩個文件或兩欄的內容
paste -d '+' file1 file2 合並兩個文件或兩欄的內容,中間用"+"區分
sort file1 file2 排序兩個文件的內容
sort file1 file2 | uniq 取出兩個文件的並集(重複的行隻保留一份)
sort file1 file2 | uniq -u 刪除交集,留下其他的行
sort file1 file2 | uniq -d 取出兩個文件的交集(隻留下同時存在於兩個文件中的文件)
comm -1 file1 file2 比較兩個文件的內容隻刪除 'file1' 所包含的內容
comm -2 file1 file2 比較兩個文件的內容隻刪除 'file2' 所包含的內容
comm -3 file1 file2 比較兩個文件的內容隻刪除兩個文件共有的部分
返回頂部索引 ^
字符設置和文件格式轉換
dos2unix filedos.txt fileunix.txt 將一個文本文件的格式從MSDOS轉換成UNIX
unix2dos fileunix.txt filedos.txt 將一個文本文件的格式從UNIX轉換成MSDOS
recode ..HTML < page.txt > page.html 將一個文本文件轉換成html
recode -l | more 顯示所有允許的轉換格式
返回頂部索引 ^
文件係統分析
badblocks -v /dev/hda1 檢查磁盤hda1上的壞磁塊
fsck /dev/hda1 修複/檢查hda1磁盤上linux文件係統的完整性
fsck.ext2 /dev/hda1 修複/檢查hda1磁盤上ext2文件係統的完整性
e2fsck /dev/hda1 修複/檢查hda1磁盤上ext2文件係統的完整性
e2fsck -j /dev/hda1 修複/檢查hda1磁盤上ext3文件係統的完整性
fsck.ext3 /dev/hda1 修複/檢查hda1磁盤上ext3文件係統的完整性
fsck.vfat /dev/hda1 修複/檢查hda1磁盤上fat文件係統的完整性
fsck.msdos /dev/hda1 修複/檢查hda1磁盤上dos文件係統的完整性
dosfsck /dev/hda1 修複/檢查hda1磁盤上dos文件係統的完整性
返回頂部索引 ^
初始化一個文件係統
mkfs /dev/hda1 在hda1分區創建一個文件係統
mke2fs /dev/hda1 在hda1分區創建一個linux ext2的文件係統
mke2fs -j /dev/hda1 在hda1分區創建一個linux ext3(日誌型)的文件係統
mkfs -t vfat 32 -F /dev/hda1 創建一個 FAT32 文件係統
fdformat -n /dev/fd0 格式化一個軟盤
mkswap /dev/hda3 創建一個swap文件係統
返回頂部索引 ^
SWAP文件係統
mkswap /dev/hda3 創建一個swap文件係統
swapon /dev/hda3 啟用一個新的swap文件係統
swapon /dev/hda2 /dev/hdb3 啟用兩個swap分區
返回頂部索引 ^
備份
dump -0aj -f /tmp/home0.bak /home 製作一個 '/home' 目錄的完整備份
dump -1aj -f /tmp/home0.bak /home 製作一個 '/home' 目錄的交互式備份
restore -if /tmp/home0.bak 還原一個交互式備份
rsync -rogpav --delete /home /tmp 同步兩邊的目錄
rsync -rogpav -e ssh --delete /home ip_address:/tmp 通過SSH通道rsync
rsync -az -e ssh --delete ip_addr:/home/public /home/local 通過ssh和壓縮將一個遠程目錄同步到本地目錄
rsync -az -e ssh --delete /home/local ip_addr:/home/public 通過ssh和壓縮將本地目錄同步到遠程目錄
dd bs=1M if=/dev/hda | gzip | ssh user@ip_addr 'dd of=hda.gz' 通過ssh在遠程主機上執行一次備份本地磁盤的操作
dd if=/dev/sda of=/tmp/file1 備份磁盤內容到一個文件
tar -Puf backup.tar /home/user 執行一次對 '/home/user' 目錄的交互式備份操作
( cd /tmp/local/ && tar c . ) | ssh -C user@ip_addr 'cd /home/share/ && tar x -p' 通過ssh在遠程目錄中複製一個目錄內容
( tar c /home ) | ssh -C user@ip_addr 'cd /home/backup-home && tar x -p' 通過ssh在遠程目錄中複製一個本地目錄
tar cf - . | (cd /tmp/backup ; tar xf - ) 本地將一個目錄複製到另一個地方,保留原有權限及鏈接
find /home/user1 -name '*.txt' | xargs cp -av --target-directory=/home/backup/ --parents 從一個目錄查找並複製所有以 '.txt' 結尾的文件到另一個目錄
find /var/log -name '*.log' | tar cv --files-from=- | bzip2 > log.tar.bz2 查找所有以 '.log' 結尾的文件並做成一個bzip包
dd if=/dev/hda of=/dev/fd0 bs=512 count=1 做一個將 MBR (Master Boot Record)內容複製到軟盤的動作
dd if=/dev/fd0 of=/dev/hda bs=512 count=1 從已經保存到軟盤的備份中恢複MBR內容
返回頂部索引 ^
光盤
cdrecord -v gracetime=2 dev=/dev/cdrom -eject blank=fast -force 清空一個可複寫的光盤內容
mkisofs /dev/cdrom > cd.iso 在磁盤上創建一個光盤的iso鏡像文件
mkisofs /dev/cdrom | gzip > cd_iso.gz 在磁盤上創建一個壓縮了的光盤iso鏡像文件
mkisofs -J -allow-leading-dots -R -V "Label CD" -iso-level 4 -o ./cd.iso data_cd 創建一個目錄的iso鏡像文件
cdrecord -v dev=/dev/cdrom cd.iso 刻錄一個ISO鏡像文件
gzip -dc cd_iso.gz | cdrecord dev=/dev/cdrom - 刻錄一個壓縮了的ISO鏡像文件
mount -o loop cd.iso /mnt/iso 掛載一個ISO鏡像文件
cd-paranoia -B 從一個CD光盤轉錄音軌到 wav 文件中
cd-paranoia -- "-3" 從一個CD光盤轉錄音軌到 wav 文件中(參數-3)
cdrecord --scanbus 掃描總線以識別scsi通道
dd if=/dev/hdc | md5sum 校驗一個設備的md5sum編碼,例如一張 CD
返回頂部索引 ^
網絡 - (以太網和WIFI無線)
ifconfig eth0 顯示一個以太網卡的配置
ifup eth0 啟用一個 'eth0' 網絡設備
ifdown eth0 禁用一個 'eth0' 網絡設備
ifconfig eth0 192.168.1.1 netmask 255.255.255.0 控製IP地址
ifconfig eth0 promisc 設置 'eth0' 成混雜模式以嗅探數據包 (sniffing)
dhclient eth0 以dhcp模式啟用 'eth0'
route -n show routing table
route add -net 0/0 gw IP_Gateway configura default gateway
route add -net 192.168.0.0 netmask 255.255.0.0 gw 192.168.1.1 configure static route to reach network '192.168.0.0/16'
route del 0/0 gw IP_gateway remove static route
echo "1" > /proc/sys/net/ipv4/ip_forward activate ip routing
hostname show hostname of system
host www.example.com lookup hostname to resolve name to ip address and viceversa(1)
nslookup www.example.com lookup hostname to resolve name to ip address and viceversa(2)
ip link show show link status of all interfaces
mii-tool eth0 show link status of 'eth0'
ethtool eth0 show statistics of network card 'eth0'
netstat -tup show all active network connections and their PID
netstat -tupl show all network services listening on the system and their PID
tcpdump tcp port 80 show all HTTP traffic
iwlist scan show wireless networks
iwconfig eth1 show configuration of a wireless network card
hostname show hostname
host www.example.com lookup hostname to resolve name to ip address and viceversa
nslookup www.example.com lookup hostname to resolve name to ip address and viceversa
whois www.example.com lookup on Whois database
GO TOP INDEX ^
Microsoft Windows networks (SAMBA)
nbtscan ip_addr netbios name resolution
nmblookup -A ip_addr netbios name resolution
smbclient -L ip_addr/hostname show remote shares of a windows host
smbget -Rr smb://ip_addr/share like wget can download files from a host windows via smb
mount -t smbfs -o username=user,password=pass //WinClient/share /mnt/share mount a windows network share
參考 https://www.php100.com/html/webkaifa/Linux/2009/1106/3485.html
https://linux.chinaunix.net/techdoc/system/2009/07/03/1121900.shtml
最後更新:2017-04-03 12:54:44