tutorials:linux_essential_commands
This is an old revision of the document!
Linux Essential Commands
man
: manual page.- Explains how to use a shell command.
man <COMMAND>
: For example, to find out how to useman
, typeman man
ls
: list directory contentcd
: change directorypwd
: print working directorywc
: count word, line, character, and bytehead
: display the first part of a file- default = 10 lines, change by
-n
- example:
head -n 20 filename
(display the first 20 lines offilename
)
tail
: display the last part of a filecat
: concatenate and print the filemore
: display output one screen at a timecp
: copy filecp <SOURCE> <DESTINATION>
mv
: move file (can be use as changing file name)mv <SOURCE> <DESTINATION>
rm
: remove file (like delete)rm -r
: remove directory (likermdir
)
chmod
: change file modes or Access Control Lists- (u,g,o): user, group, other
- (r,w,x): read, write, execute
chown
: change file owner or groupmkdir
: make directoriesrmdir
: remove directoriesfind
: 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 nameflash
.- These examples are useful for calculating file sizes or clean up.
- To calculate all file sizes, pipe the file names to
xargs
anddu
;find /PATH -type f -name “*.bam” | xargs du -csh
- To remove all files found by the command, pipe the file names to
xargs
andrm
;find /PATH -type f -name “*.bam” | xargs rm
ssh
: OpenSSH SSH client (remote login program)ssh usrname@ip_adress
scp
: secure copy (remote file copy program)scp <SOURCE> USRNAME@IP:<DESTINATION>
scp USRNAME@IP:<SOURCE> <DESTINATION>
- -p: 保留原始檔案權限&修改日期等, -r: 複製整個資料夾
2>&1
: send STDERR to STDOUT (0:STDIN, 1:STDOUT, 2:STDERR)&
: running job in background (終端機背景執行)- example:
<COMMAND> &
- the job may be terminated if you log out
nohup
: run a command in background; immune to hangups 系統背景執行nohup <COMMAND> &
- This is different from
<COMMAND> &
; logging out would not affect the job
free
: display amount of free and used memory in the systemfree -g
: Display the amount of memory in gibibytes
grep
: find keywords in filegrep <KEYWORD> <FILENAME>
nice
andrenice
: 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
:
tutorials/linux_essential_commands.1588047300.txt.gz · Last modified: 2020/04/28 12:15 by chkuo