記錄常用linux指令(持續更新)

lscpu

用來顯示cpu的相關信息

free -h

以G為單位來顯示內存的信息。

locate

locate your_file_name 即可查找指定文件。

df / du

區別:
df 官方解釋 :
Show information about the file system on which each FILE resides,
or all file systems by default.
顯示每個文件所在的文件系統的信息,或默認的所有文件系統。
du 官方解釋:
Summarize disk usage of each FILE, recursively for directories.
遞歸地總結每個文件的磁盤使用情況。

常用命令:
df -h 查看磁盤空間大小

du -sh * 當前目錄下文件或目錄的大小
du -h -d 1 顯示當前目錄下文件大小或目錄的大小,并顯示當前目錄總占用大小
du -sh * | sort -nr | head 顯示前十個占用空間最大的文件或目錄

df --help 查看幫助df 幫助文檔

[root@iZ2ze15dbhsx4gje8d4h75Z target]# df --help
Usage: df [OPTION]... [FILE]...
Show information about the file system on which each FILE resides,
or all file systems by default.

Mandatory arguments to long options are mandatory for short options too.
  -a, --all             include dummy file systems
  -B, --block-size=SIZE  scale sizes by SIZE before printing them; e.g.,
                           '-BM' prints sizes in units of 1,048,576 bytes;
                           see SIZE format below
      --direct          show statistics for a file instead of mount point
      --total           produce a grand total
  -h, --human-readable  print sizes in human readable format (e.g., 1K 234M 2G)
  -H, --si              likewise, but use powers of 1000 not 1024
  -i, --inodes          list inode information instead of block usage
  -k                    like --block-size=1K
  -l, --local           limit listing to local file systems
      --no-sync         do not invoke sync before getting usage info (default)
      --output[=FIELD_LIST]  use the output format defined by FIELD_LIST,
                               or print all fields if FIELD_LIST is omitted.
  -P, --portability     use the POSIX output format
      --sync            invoke sync before getting usage info
  -t, --type=TYPE       limit listing to file systems of type TYPE
  -T, --print-type      print file system type
  -x, --exclude-type=TYPE   limit listing to file systems not of type TYPE
  -v                    (ignored)
      --help     display this help and exit
      --version  output version information and exit

Display values are in units of the first available SIZE from --block-size,
and the DF_BLOCK_SIZE, BLOCK_SIZE and BLOCKSIZE environment variables.
Otherwise, units default to 1024 bytes (or 512 if POSIXLY_CORRECT is set).

SIZE is an integer and optional unit (example: 10M is 10*1024*1024).  Units
are K, M, G, T, P, E, Z, Y (powers of 1024) or KB, MB, ... (powers of 1000).

FIELD_LIST is a comma-separated list of columns to be included.  Valid
field names are: 'source', 'fstype', 'itotal', 'iused', 'iavail', 'ipcent',
'size', 'used', 'avail', 'pcent', 'file' and 'target' (see info page).

GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
For complete documentation, run: info coreutils 'df invocation'

du --help 查看幫助文檔

[root@iZ2ze15dbhsx4gje8d4h75Z target]# du --help
Usage: du [OPTION]... [FILE]...
  or:  du [OPTION]... --files0-from=F
Summarize disk usage of each FILE, recursively for directories.

Mandatory arguments to long options are mandatory for short options too.
  -0, --null            end each output line with 0 byte rather than newline
  -a, --all             write counts for all files, not just directories
      --apparent-size   print apparent sizes, rather than disk usage; although
                          the apparent size is usually smaller, it may be
                          larger due to holes in ('sparse') files, internal
                          fragmentation, indirect blocks, and the like
  -B, --block-size=SIZE  scale sizes by SIZE before printing them; e.g.,
                           '-BM' prints sizes in units of 1,048,576 bytes;
                           see SIZE format below
  -b, --bytes           equivalent to '--apparent-size --block-size=1'
  -c, --total           produce a grand total
  -D, --dereference-args  dereference only symlinks that are listed on the
                          command line
  -d, --max-depth=N     print the total for a directory (or file, with --all)
                          only if it is N or fewer levels below the command
                          line argument;  --max-depth=0 is the same as
                          --summarize
      --files0-from=F   summarize disk usage of the
                          NUL-terminated file names specified in file F;
                          if F is -, then read names from standard input
  -H                    equivalent to --dereference-args (-D)
  -h, --human-readable  print sizes in human readable format (e.g., 1K 234M 2G)
      --inodes          list inode usage information instead of block usage
  -k                    like --block-size=1K
  -L, --dereference     dereference all symbolic links
  -l, --count-links     count sizes many times if hard linked
  -m                    like --block-size=1M
  -P, --no-dereference  don't follow any symbolic links (this is the default)
  -S, --separate-dirs   for directories do not include size of subdirectories
      --si              like -h, but use powers of 1000 not 1024
  -s, --summarize       display only a total for each argument
  -t, --threshold=SIZE  exclude entries smaller than SIZE if positive,
                          or entries greater than SIZE if negative
      --time            show time of the last modification of any file in the
                          directory, or any of its subdirectories
      --time=WORD       show time as WORD instead of modification time:
                          atime, access, use, ctime or status
      --time-style=STYLE  show times using STYLE, which can be:
                            full-iso, long-iso, iso, or +FORMAT;
                            FORMAT is interpreted like in 'date'
  -X, --exclude-from=FILE  exclude files that match any pattern in FILE
      --exclude=PATTERN    exclude files that match PATTERN
  -x, --one-file-system    skip directories on different file systems
      --help     display this help and exit
      --version  output version information and exit

Display values are in units of the first available SIZE from --block-size,
and the DU_BLOCK_SIZE, BLOCK_SIZE and BLOCKSIZE environment variables.
Otherwise, units default to 1024 bytes (or 512 if POSIXLY_CORRECT is set).

SIZE is an integer and optional unit (example: 10M is 10*1024*1024).  Units
are K, M, G, T, P, E, Z, Y (powers of 1024) or KB, MB, ... (powers of 1000).

GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
For complete documentation, run: info coreutils 'du invocation'

nohup 持續不掛斷的后臺運行
nohup java -jar demo.jar >./log.txt 2>&1 &
設置初始java 堆的最大值,最小值,加載配置文件
nohup java -Xms4g -Xmx4g -jar sems.jar --spring.config.location=/opt/exam/conf/app.properties > ./nohup.out 2>&1 &


history
列出歷史命令
history
列出最近運行的5條指令
history 5

ctrl + r 查找以前(歷史)輸入的命令


tail 命令常用
監視filename文件,刷新顯示在屏幕
tail -f filename
顯示filename文件最后100行
tail -n 100 filename


mkdir 創建一個空目錄
mkdir filename
遞歸創建多個目錄
mkdir -p test/test1
刪除空目錄
rmkdir filename
rmkdir /opt/exam
強制刪除一個目錄中的一個或多個文件或目錄 (慎用)
rm -rf filename


unzip
把文件解壓到當前目錄下
unzip test.zip
把文件解壓到指定的目錄下,-d參數。
unzip -d /temp test.zip
解壓的時候,不想覆蓋已經存在的文件,加上-n參數
unzip -n test.zip
解壓的時候,覆蓋已經存在的文件,加上-o參數
unzip -o test.zip
unzip -n -d /temp test.zip
執行的的時候不顯示任何信息,加上-q參數
unzip -q test.zip
查看壓縮文件目錄,但不解壓
unzip -v test.zip

zip
將當前目錄下的指定目錄,壓縮為.zip文件
zip -q -r xxxx.zip <dir name>
將指定目錄下的所有文件及其文件夾,壓縮為.zip文件
zip -q -r xxx.zip /<path to dir>


tar
https://www.cnblogs.com/newcaoguo/p/5896975.html


pwd 查看當前所在路徑
pwd


tree 以樹狀圖列出當前目錄結構
tree


chmod 權限
擁有者有讀、寫、執行權限;而屬組用戶和其他用戶只有讀、執行權限。
chmod 755 filename
所有用戶都有文件讀、寫權限
chmod 666 filename
所有用戶都有讀、寫、執行權限。
chmod 777 filename


ps是顯示當前狀態處于running的進程,grep表示在這些里搜索,而ps aux是顯示所有進程和其狀態。
ps aux | grep java
殺死相應的進程
kill -9 pid
殺死所有java進程
pkill -9 java


ll 羅列出當前文件或目錄的詳細信息,含有時間、讀寫權限、大小、時間等信息 ,像Windows顯示的詳細信息。
ll
ls 只列出文件名或目錄名 就象windows里的 列表
ls


vim 中查找字符串
/后跟查找的字符串。vim會顯示文本中第一個出現的字符串。
?后跟查找的字符串。vim會顯示文本中最后一個出現的字符串。


查詢磁盤使用情況
全部
df -h
單個目錄下
du -h -d 1

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容