User Tools

Site Tools


tutorials:linux_essential_commands

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
tutorials:linux_essential_commands [2012/03/02 11:51] wanchiatutorials:linux_essential_commands [2023/10/03 13:03] (current) chkuo
Line 3: Line 3:
     * Explains how to use a shell command.      * Explains how to use a shell command. 
     * ''man <COMMAND>'': For example, to find out how to use ''man'', type ''man man''     * ''man <COMMAND>'': For example, to find out how to use ''man'', type ''man man''
-  * ''passwd'': modify a user's password 
   * ''ls'': list directory content   * ''ls'': list directory content
   * ''cd'': change directory   * ''cd'': change directory
   * ''pwd'': print working directory   * ''pwd'': print working directory
   * ''wc'': count word, line, character, and byte   * ''wc'': count word, line, character, and byte
-  * ''head'': display first 10 lines of a file+  * ''head'': display the first part of a file 
 +    * default = 10 lines, change by ''-n'' 
 +    * example: ''head -n 20 filename'' (display the first 20 lines of ''filename'')
   * ''tail'': display the last part of a file   * ''tail'': display the last part of a file
   * ''cat'': concatenate and print the file   * ''cat'': concatenate and print the file
Line 24: Line 25:
   * ''mkdir'': make directories   * ''mkdir'': make directories
   * ''rmdir'': remove directories   * ''rmdir'': remove directories
 +  * ''find'': search for files
 +    * examples:
 +      * ''find /PATH -type f -name "*.bam"'': find all files (''-type f'') in ''/PATH'' with the name ''*.bam''.
 +      * ''find /PATH -type d -name "flash"'': find all directories (''-type d'') in ''/PATH'' with the name ''flash''.
 +      * These examples are useful for calculating file sizes or clean up. 
 +      * To calculate all file sizes, pipe the file names to ''xargs'' and ''du''; ''find /PATH -type f -name "*.bam" | xargs du -csh''
 +      * To remove all files found by the command, pipe the file names to ''xargs'' and ''rm''; ''find ./ -type f -name "*.bam" | xargs rm''
 +      * To remove all directories found by the command, pipe the directory names to ''xargs'' and ''rm -r''; ''find ./ -type d -name "bwa_*" | xargs rm -r''
   * ''ssh'': OpenSSH SSH client (remote login program)   * ''ssh'': OpenSSH SSH client (remote login program)
     * ''ssh usrname@ip_adress''     * ''ssh usrname@ip_adress''
   * ''scp'': secure copy (remote file copy program)   * ''scp'': secure copy (remote file copy program)
-    * ''scp <SOURCE> usrname@ip_adress:<DESTINATION>'' +    * ''scp <SOURCE> USRNAME@IP:<DESTINATION>'' 
-    * -p: 保留原始檔案權限&修改日期等 +    * ''scp USRNAME@IP:<SOURCE> <DESTINATION>'' 
-    * -r: 複製整個資料夾+    * -p: 保留原始檔案權限&修改日期等-r: 複製整個資料夾
   * ''2>&1'': send STDERR to STDOUT (0:STDIN, 1:STDOUT, 2:STDERR)   * ''2>&1'': send STDERR to STDOUT (0:STDIN, 1:STDOUT, 2:STDERR)
   * ''&'': running job in background (終端機背景執行)   * ''&'': running job in background (終端機背景執行)
-  * ''nohup'': 系統背景執行(不同於&+    * example: ''<COMMAND> &'' 
 +    * the job may be terminated if you log out 
 +  * ''nohup'': run a command in background; immune to hangups 系統背景執行
     * ''nohup <COMMAND> &''     * ''nohup <COMMAND> &''
-  * ''free -g'': 查看實際剩餘ram(單位為G)+    * This is different from ''<COMMAND> &''; logging out would not affect the job 
 +  * ''kill'': kill job 
 +    * ''kill PID'': kill a job by the process id (PID) 
 +    * ''ps -u USER | grep blast | cut -d ' ' -f 2 | xargs kill'': generate a list of all processes by USER, use ''grep'' to find blast jobs, ''cut'' out the PID, send to ''xargs'' to kill the jobs. 
 +  * ''free'': display amount of free and used memory in the system 
 +    * ''free -g'': Display the amount of memory in gibibytes
   * ''grep'': find keywords in file   * ''grep'': find keywords in file
     * ''grep <KEYWORD> <FILENAME>''     * ''grep <KEYWORD> <FILENAME>''
 +  * ''nice'' and ''renice'': run a program with modified priority. If the server is under heavy load and you need to start a non-urgent large job, please use these.'
 +  * ''diff'':
 +  * ''wget'': download files
 +    * example: download all '*gz' files in the link; use the '-e' command to force ignore the robot file (use with care)
 +      * ''wget -r --no-parent -e robots=off -A '*.gz' https://www.example.com/files/''
 +
 +
tutorials/linux_essential_commands.1330660276.txt.gz · Last modified: by wanchia