Section 1 Overview
还是有些东西不太熟,记不太清,下面记录
/etc/fstab Local file system settings
/etc/mtab Mounted file system settins
/etc/inittab System startup settings
/etc/exports NFS share settings
/etc/resolve.conf DNSsettings
/etc/issue Message displayed at shell login
/etc/profile Shell envirement settings
/var/log/messages Kernel messages log file
/var/log/wtmp Current user login file
/var/log/btmp 应该是记录登录失败的
/var/log/lastlog User login history file
/var/log/kernel.log Kernel log file
/var/log/syslog Syslog message log file
里面的wtmp,lastlog等有些是二进制文件,不能直接查看,要用到命令strings来查看,这个要记住
Section 2 Basics
记录一下一些我用的也比较少,不熟的命令
whatis Display a description of the specified command
-w 这个比较牛B,可以模糊查找出不少命令,比如 whatis -w *tree
tree Display the contents of a directory in a tree hierarchy format
-L [num] 可以选择列出多少级目录
find Search for files and directories
-name -user -perm -mtime 不解释
file Display the file type of the specified file
stat Display extended information about a file system, file, or directory
-f [FILESYSTEM] Display information for the specified file system
history Display commands that have recently been executed
cd *****
cd - Go back to the previous working directory 这个我用的少
Section 3 Advanced
touch Update time stamps on a file. 可以用来创建新文件
-a [FILE] Update the access time stamp on the specified file
-m [FILE] Update the modified time stamp on the specified file
lsof List open files.
[FILE] List information about a specific file
-u [USERNAME] List files open by the specified user
-p [PID] List open files by the specified PID number
-c [PROCESSNAME] List open files with the specified process name
-i List open network ports and sockets
fuser Display information about open files.
[FILE] Display processes using the specified file
-v [FILE] Display detailed information about the fi
-ki [FILE] Kill all processes using the specified file
cksum Display the checksum of a file.
md5sum Display the MD5 hash of a file.
gzip/gunzip Compress/uncompress files.
split Split large files into multiple pieces.
-b [SIZE] [FILE] [OUTPUT] Split a file into multiple pieces
-d -b [SIZE] [FILE] [OUTPUT] Use numeric suffixes
shred Securely erase files.
watch Periodically execute the specified command.
[COMMAND] Run the specified command every 2 seconds
-n [NUM] [COMMAND] Run a command at the specified interval
env Display environment variables. 查看环境变量
Section 4 Text Editing
nano Simple text editor 我没用过,表示自己凹凸了
tac Concatenate files in reverse order
wc Count the number of lines, words, and characters in a file
显示的三个分别是 单词数 行数 字符数
more 不解释,有个参数不知道而已
+[NUM] [FILE] Start reading a file at the specified line number
head Display the first part of a file.
tail Display the last part of a file.
tee Display the output of a command and write the output to a file
zcat Read the contents of a compressed file
Section 5 User Group Security
umask Display/set a user's default file creation mask
就是用户新建文件的默认权限的意思吧
w Display detailed information about users logged in to the system.
这个命令调用的应该是/var/log/wtmp这个日志文件吧
last/lastb Display the last successful/failed user logins.
应该调用的是/var/log/wtmp和btmp吧
lastlog Display the most recent user login information
这个不知道调用哪个文件了
finger Display information a about user account.
显示的plan挺好玩的,显示的是个人文件夹下.plan的内容
wall Broadcast a message to all users on the system.
广播消息,每个用户的每个终端都会弹窗
输完之后,按ctr+D发送
ulimit Display/set system resource limits.
这个资源限制就真的用的很少了
Section 6 Process Control and Scheduling
pstree Display all running processes in a tree view
-a Include command line options for each process
个人觉得这个命令超级好玩超级直观,超级喜欢
renice Alter the priority of a running process
记住数字越小,越优先
jobs Display background and suspended jobs
nohup Run a process immune to hang-up signals.
batch Schedule programs to run during low CPU load.
at Schedule programs to run at the specified time.
这个的时间表述很人性化,可以用am now + minutes 什么的
例如 at now + 15 minutes
atq Display queued at jobs.
atrm Remove scheduled at jobs from the queue.
crontab Schedule programs to run at the specified time(s)
这个还是不懂,懒得研究,用的少
Section 7 Startup and Shutdown
telinit Change the runlevel
runlevel Display the previous and current runlevel
service Manage services on a Linux system
--status-all Display the status of all services
这个是之前不会的,restart stop什么的就带过了
update-rc.d Display and edit services to start
[service] remove 删除启动项
[service] defaults 添加启动项
这条命令是自己最近折腾出来的,开心
Section 8 Network Commands
ifup/ifdown Enable/disable network interfaces
这就是传说中的启用禁用网卡吧
iwconfig Display wireless network interfaces
这个是之前见都没见过的,可以看到很多信息
ethtool Display and edit ethernet card settings.
whois Lookup domain name registry information in the whois database
一个输入一行可以输出一大堆东西的命令
netstat Display network connections, statistics, and routing information
不带参数的话显示接口连接
-s Display network statistics
-r Display routing information
ifstat Display network interface statistics
wget File download utility for Linux systems.
Linux下的简单下载工具
Section 9 Hardware Management Commands
lshw List hardware on Linux systems
-short Display a simple hardware listing
short就够了,不然就太详细了
dmidecode Display detailed information about devices on the system.
hdparm Display/set hard drive parameters on Linux systems.
Section 10 File Systems
fdisk Display and edit hard disk partitions
parted Display and edit partitions on Linux systems
fsck Check and repair file systems
badblocks Check a disk drive for bad blocks
mkswap Create swap space storage
swapon/swapoff Activate/deactivate swap space
sync Flush file system buffers
Section 11 Backup and Restore Commands
tar Create/extract archive files.
-cvf [FILE] [ITEM] Backup the specified item(s)
-czvf [FILE] [ITEM] Compress the archive to save space
-xvf [FILE] [ITEM] Restore the specified item(s)
-tf [FILE] List all files in the specified archive
dump Create incremental backups.
-0 -uf [OUTPUT] [INPUT] Create a full backup
-[NUM] -uf [OUTPUT] [INPUT] Create an incremental backup
restore Restore files from dump archives.
dd Create raw copies of data devices
慎用
cpio Create/extract cpio archives.
Section 12 Monitoring and Troubleshooting
top Monitor system performance and running processes.
vmstat Display virtual memory usage information.
-s Display a table of memory statistics
free Display system memory and swap space usage information.
-m Display memory usage in megabytes
df Display file system usage information
-h Display sizes in human readable format (i.e., megabytes and gigabytes)
du Display disk usage.
-hs [DIRECTORY] Display the size of the specified directory
uptime Display how long the system has been online.
dmesg Display kernel log messages.
查看日志文件的命令,和 grep fail结合使用
strace Trace system calls and signals
太高深了,不会
lsmod Display Linux kernel module information.
insmod/rmmod Install/remove kernel modules
关于模块的命令没尝试过
modinfo Display information about Linux kernel modules.
sysctl Display and edit kernel parameters on Linux and BSD systems
-a Display all kernel parameters
-w [SETTING]=[VALUE] Set the specified kernel parameter
-a会出一堆东西的,这个避免直接去修改/proc的内容
Section 13 Printing Commands
略
Section 14 Software Installation
dpkg Install /remove Debian Linux software packages.
-i [PACKAGE] Install the specified package
-r [PACKAGE] Remove the specified package
-p [PACKAGE] Remove the specified package and related config files
-l List all installed packages
关于dpkg的命令还是经常会使用到。注意-p
aptitude Automated package manager for Debian Linux-based systems.
貌似强大,没用过
rpm Install /remove Red Hat Linux packages.
-i [PACKAGE] Install the specified package
-U [PACKAGE] Upgrade the specified package
-e [PACKAGE] Remove the specified package
-qa List all installed packages
我只能表示,R系的命令我很不熟,记下先
yum Automated package manager for Red Hat Linux-based systems.