Linux 常用命令整理

网络安全:查看Linux服务器是否被入侵
如果ps命令或netstat命令找不到,可以断定网络被入侵。
第一步:查看异常账户
last: 查看服务器近期登陆的账户记录
或者查看/var/log/secure日志,如果有除root外的用户登陆过,
检查/etc/passwd这个文件,看是否有异常账户,
有的话使用命令“usermod -L username” 禁用用户。
或则使用“userdel -r username” 删除用户。

Linux终端使用技巧=================================
Shift+Ctrl+T        :新建标签页
Shift+Ctrl+W        :关闭标签页
Ctrl+PageUp			:前一标签页
Ctrl+PageDown       :后一标签页
Shift+Ctrl+PageUp   :标签页左移
Shift+Ctrl+PageDown :标签页右移
Alt+1               :切换到标签页1
Alt+2               :切换到标签页2
Alt+3               :切换到标签页3
Shift+Ctrl+N        :新建窗口
Shift+Ctrl+Q        :关闭终端
终端中的复制/粘贴  :
Shift+Ctrl+C        :复制
Shift+Ctrl+V        :粘贴
终端改变大小        :
F11                 :全屏
Ctrl+plus           :放大
Ctrl+minus          :减小
Ctrl+0              :原始大小
点击查看更多

# ------ Linux basic :FR ---------------------------
# configure the Global environment variable
#  modify the /etc/bashrc, /etc/vimrc with su root

# ------ Generic Symbol :FR ------------------------
/             : root directory
~             : usr directory
./            : current directory path
..            : up directory path
!cmd          : invoke last command (history)
&             : run job in background

# --- create a linux user and group :FR  ----------
adduser user_name : you must have root privilege
passwd  user_name : set the password for the user
su      user_name : change user account and need the user password
id                : print read and effective user and group IDs
newgrp svn_proj   : log in to a new group
whoami            : display the user name
man cmd           : manual and input "q" to quit man command
# ------ file operation :FR -----------------------
ls            : list the directory and files
ls -a         : list all includes hidden directory and files
ls -l         : format list  
ll -a         : format list 

cd            : change directory to the /home/user
cd ~          : ~ means the /home/user directory
cd dir_path   : go to the dir_path directory

pwd           : present working directory

mkdir dir     : create a directory
touch file    : create a file
vi file       : vi editor
gvim file     : gvim editor

cat  file     : look at the file context on terminal
more file     : view the file
less file     : view the file like gvim or vi

chmod 777 dir                    : change r/w/x property 
chmod a+x file                   : file will be executed by all
chmod [ugoa]+[rwx] file|dir
chown user:group files|directory : change file owner and group
chgrp gourp_name files           : change file group

cp -f file1 file2      : copy file1 to file2
cp -r dir1 dir2        : copy directory recursively
                       
mv file1 dir|file2     : move (or rename) file1 to file2
                       
wc file                : count lines words and characters
wc -w file             : count word of file
wc -l file             : count line  
                       
rm file                : remove file
rm -r dir              : remove dir* (recursive)
rm -f file             : enforced to remove file (force)
rm -rf dir             : enforced to remove dir*

ln -s file link        : create a symbolic link to file

grep pattern file      : search pattern matched in file
grep error sim.log     :
grep -r pattern dir    : search pattern incursively in directory

find / -name file_name : search the file from / directory
find /etc -name '*con*':
find / -size +100M     :

grep ERROR cmp.log > error.log
grep ERROR sim.log >> error.log
cat > file : sample the standard input and put them into the file

cmd | grep pattern  : search pattern in cmd output
grep -nir ERROR sim.log | tee -a error.log
rpm -qa | grep vim
cat /etc/passwd | grep /bin/bash | wc -l
man ls | col -b > ls_man.txt

#------ pack files :FR -------------------------
tar -cvf file.tar files         : create a tar file
tar -xvf file.tar               : extract a tar file
tar -czvf file.tar.gz files     : create a gzip file
tar -xzvf file.tar.gz           
tar -cjvf file.tar.bz2 files    : create a bzip2 file
tar -xjvf file.tar.bz2

gzip file                       : create a file.gz file
gzip -d file.gz                 :

# ------ install rpm package :FR------------------
rpm -qa           : query all installed RPM packages
rpm -ivh RPM.rpm  : install RPM package

./configure       : configure the rpm source
make
make install

yum               : yellowdog update modifier
#------ process manage :FR-------------------------
ps           : display the current active process
top          : display all process of the OS; press the key "q" to quit
kill -9 pid  : stop the pid process
killall proc : stop all of the proc process
bg           : list the suspended job in background
fg           : resume the last suspended job in foreground

#------ system info :FR----------------------------
df                 : report file system disk space usage
df -hT             :
df -i              : list inode information instead of block usage
du -b|k|m file|dir : estimate file space usage
du -s file|dir     : summary
du -sm file|dir  

cat /proc/cpuinfo  : show CUP information
cat /proc/meminfo  : show memory information

date          : display system time 
date +%Y%m%d 	
date +%s      
date +%N

cal           : display calendar
uptime        : 
w             : display who logon and what are doing
whoami 		  : print effective userid
uname -a      : display all OS system info

which cmd     : show the full path of the cmd
su root|usr   : change the usr
exit          : usr shell quit
echo $PATH    : show the variable
clear         : clear the info on the terminal 
history       : show the command history
!cmd          : invoke the last cmd
make          : invoke Makefile
make clean; make cpl; make sim  :

# ------ network info :FR---------------------
ping host|IP   : ping IP address and print the result
hostname       : display system host name
ifconfig -a    : configure the network

# ------ hot key :FR -------------------------
ctrl + c  : stop the current command
ctrl + z  : suspend the job and put it into background
            'fg' can be used to resume the job
            free the license and take it soon
ctrl + d  : display directory in cd command

  • FR-370

    Ubunt vbox share: sudo usermod -aG vboxsf $(whoami)

    5年前 (2020-09-11)      回复
    回复FR-370
  • FR-605

    1. strings /usr/lib64/libstdc++.so.6 | grep GLIBC
    2. find / -name "libstdc++.so*"
    3. ln -s libstdc++.so.6.0.21 libstdc++.so.6
    4. strings /usr/lib64/libstdc++.so.6 | grep GLIBC

    5年前 (2020-05-20)      回复
    回复FR-605
  • FR-123

    不错

    5年前 (2019-11-05)      回复
    回复FR-123