投递文章投递文章 投稿指南投稿指南 RSS订阅RSS订阅

Linux命令行大全 v1.0

来源:iT堂整理 发布时间:2008-01-06 收藏 投稿 字体:【

Linux的命令行操作简洁效率高,就是数量有点多.
linuxguide.it整理了多达350条以上的Linux命令行命令,并给出了相应的说明可供您速查用.
无论是Linux新手还是老鸟都应该留一份备用,毕竟日常工作中我们不能带着参考书走.

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


 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


 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)


 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


 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


 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)


 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
alias hh='history'  set an alias for a command - hh = history


 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

最新5条评论 查看所有评论
评论内容:请自觉遵守互联网相关政策法规。
用户名: 密码: 匿名 注册
热门文章
随机推荐
About iTtang - 联系方法  - 专题列表 - 友情链接  -  高级搜索   -  帮助中心  -