unnatural 石原里美 入坑了她的美
Linux基本知识
查询命令 man
linux的命令和参数太多,而且容易记错,我们可以通过man [命令] 来查看如何命令的使用文档,这才是学习命令最好的办法。
其次要首先搞懂:文件,用户与组的概念。
man ls
or
ls --help
会以中文展示出来。
Tips:
- Use the manual man for more information on commands.
- If you want to rerun a command you can use the up-arrow key to recall the previous entry.
- You can press TAB to ask your shell to try to complete a file name. It is convenient! Always try to have the shell fill in the filename for you, that way you will never mistype these”
摘录来自: “The Biostar Handbook: 2nd Edition。” Apple Books.
Linux的文件权限和目录配置
用户组与用户
其中 老王家就代表一个用户组 ,单个人代表为用户。
- linux的用户是记录在
/etc/passwd- 密码记录在
/etc/shadow- 所有的组记录在
/etc/group
添加新用户 :
1 | adduser wvdon |
添加用户之后可以把用户添加到相应的组中。
1 | groupadd lab |
新建的用户如果想使用root,将bashrc copy 过去。
如果新建的用户没有用户目录,就新建一下用户目录。
sudo cp /home/wvdon/.bashrc /home/labuser/.bashrc
文件权限
文件的权限被分为 可读(read) 可写(write) 可执行(execute) 简称为 r w x
用数字表示 r:4 w:2 x:1
文件显示的权限
1
2 -rw-rw-r-- 1 wuweidong061 wvdon 0 Oct 18 23:08 testfile.txt
①第一个符合 为 d 或者 - 分别代表 文件夹或者文件
②2-4符号代表所属用户的权限 rw- 即可读可写(4+2+0)
③5-7符号代表所属用户组的权限 rw- 即可读可写(4+2+0)
④8-10符号代表其他用户的权限为r–仅读(4)
⑤代表连接数
⑥代表 文件所有者 wuweidong061
⑦代表 文件所属用户组 wvdon
⑧时间代表文件最后修改的时间
⑨文件名
修改文件用户与权限的三个命令
chgrp
1 | chgrp=change group |
chown
1 | chown=change owner |
chmod
1 | chmod = chmod mode |
对文件与目录的常见操作
1. ls
列出文件或者目录的信息,目录的信息就是其中包含的文件。
1 | # ls [-aAdfFhilnrRSt] file|dir |
2. cd
更换当前目录。
1 | cd [相对路径或绝对路径] |
3. mkdir
创建目录。
1 | # mkdir [-mp] 目录名称 |
4. rmdir
删除目录,目录必须为空。
1 | rmdir [-p] 目录名称 |
5. touch
更新文件时间或者建立新文件。
1 | # touch [-acdmt] filename |
6. cp
复制文件。如果源文件有两个以上,则目的文件一定要是目录才行。
1 | cp [-adfilprsu] source destination |
7. rm
删除文件。
1 | # rm [-fir] 文件或目录 |
8. mv
移动文件。
1 | # mv [-fiu] source destination |
“How do I view the data one page at a time”
1 | more file |
Biostat:
cat SGD_features.tab |cut -f 2|sort |uniq -c|sort -rn|head
tree
Rsync|scp
cut
awk
shell 脚本
$1,$2 可以在终端依次接受参数。
1 | for name in *.fastq; do |
1 | begin=$(date +%s -d $class) |
md5sum chr22.fa.gz >md5.txt
md5sum -c md5.txt
进程管理
Ctrl + Z : 终止执行
Ctrl + C :暂停执行,挂到后台。
jobs :查看在后台执行的进程
& : 命令末尾加上,可在后台执行。
fg n: 将命令进程号码为N的命令进程放到前台执行
bg n :将命令进程号码为N的命令进程放到后台执行
1 | nohup comand &>nohup.out |
附表
命令缩写一览表
摘要
每每都会忘记linux命令,不过我记得全拼的时候可能就能想起来了。
wc :word counter(计算行数,单词数,字母数) “prints the number of lines, words, and characters in the stream:”
ls:list(列出目录内容)
cd:Change Directory(改变目录)
su:switch user 切换用户
rpm:redhat package manager 红帽子打包管理器
pwd:print work directory 打印当前目录显示出当前工作目录的绝对路径
ps: process status(进程状态,类似于 windows 的任务管理器)
常用参数:-auxf
ps -auxf 显示进程状态
df: disk free 其功能是显示磁盘可用空间数目信息及空间结点信息。换句话说,就是报告在任何安装的设备或目录中,还剩多少自由的空间。
rpm:即 RedHat Package Management,是 RedHat 的发明之一
rmdir:Remove Directory(删除目录)
rm:Remove(删除目录或文件)
cat: concatenate 连锁 cat file1 file2>>file3把文件1和文件2的内容联合起来放到 file3中
insmod: install module,载入模块
ln -s : link -soft 创建一个软链接,相当于创建一个快捷方式
mkdir:Make Directory(创建目录
touch
man: Manual
pwd:Print working directory
su:Swith user
cd:Change directory
ls:List files
ps:Process Status
mkdir:Make directory
rmdir:Remove directory
mkfs: Make file system
fsck:File system check
cat: Concatenate
uname: Unix name
df: Disk free
du: Disk usage
lsmod: List modules
mv: Move file
rm: Remove file
cp: Copy file
ln: Link files
fg: Foreground
bg: Background
chown: Change owner
chgrp: Change group
chmod: Change mode
umount: Unmount
dd: 本来应根据其功能描述“Convert an copy”命名为“cc”,但“cc”已经被用以代表“C Complier”,所以命名为“dd”
tar:Tape archive
ldd:List dynamic dependencies
insmod:Install module
rmmod:Remove module
lsmod:List module
文件结尾的”rc”(如.bashrc、.xinitrc 等):Resource configuration
Knnxxx / Snnxxx(位于 rcx.d 目录下):K(Kill);S(Service);nn(执行顺序号);xxx(服务标识)
.a(扩展名 a):Archive,static library
.so(扩展名 so):Shared object,dynamically linked library
.o(扩展名 o):Object file,complied result of C/C++ source file
RPM:Red hat package manager
dpkg:Debian package manager
apt:Advanced package tool(Debian 或基于 Debian 的发行版中提供)
bin = BINaries
/dev = DEVices
/etc = ETCetera
/lib = LIBrary
/proc = PROCesses
/sbin = Superuser BINaries
/tmp = TeMPorary
/usr = Unix Shared Resources
/var = VARiable ?
FIFO = First In, First Out
GRUB = GRand Unified Bootloader
IFS = Internal Field Seperators
Tk = ToolKit
VT = Video Terminal
YaST = Yet Another Setup Tool
apache = “a patchy” server
apt = Advanced Packaging Tool
ar = archiver
as = assembler
awk = “Aho Weiberger and Kernighan” 三个作者的姓的第一个字母
bash = Bourne Again SHell
bc = Basic (Better) Calculator
bg = BackGround
biff = 作者 Heidi Stettner 在 U.C.Berkely 养的一条狗,喜欢对邮递员汪汪叫。
cal = CALendar
cat = CATenate
cd = Change Directory
chgrp = CHange GRouP
chmod = CHange MODe
chown = CHange OWNer
chsh = CHange SHell
cmp = compare
cobra = Common Object Request Broker Architecture
comm = common
cp = CoPy
cpio = CoPy In and Out
cpp = C Pre Processor
cron = Chronos 希腊文时间
cups = Common Unix Printing System
cvs = Current Version System
daemon = Disk And Execution MONitor
dc = Desk Calculator
dd = Disk Dump
df = Disk Free
diff = DIFFerence
dmesg = diagnostic message
du = Disk Usage
ed = editor
egrep = Extended GREP
elf = Extensible Linking Format
elm = ELectronic Mail
emacs = Editor MACroS
eval = EVALuate
ex = EXtended
exec = EXECute
fd = file descriptors
fg = ForeGround
fgrep = Fixed GREP
fmt = format
fsck = File System ChecK
fstab = FileSystem TABle
fvwm = F*** Virtual Window Manager
gawk = GNU AWK
gpg = GNU Privacy Guard
groff = GNU troff
hal = Hardware Abstraction Layer
joe = Joe’s Own Editor
ksh = Korn SHell
lame = Lame Ain’t an MP3 Encoder
lex = LEXical analyser
lisp = LISt Processing = Lots of Irritating Superfluous Parentheses
ln = LiNk
lpr = Line PRint
ls = list
lsof = LiSt Open Files
m4 = Macro processor Version 4
man = MANual pages
mawk = Mike Brennan’s AWK
mc = Midnight Commander
mkfs = MaKe FileSystem
mknod = MaKe NODe
motd = Message of The Day
mozilla = MOsaic GodZILLa
mtab = Mount TABle
mv = MoVe
nano = Nano’s ANOther editor
nawk = New AWK
nl = Number of Lines
nm = names
nohup = No HangUP
nroff = New ROFF
od = Octal Dump
passwd = PASSWorD
pg = pager
pico = PIne’s message COmposition editor
pine = “Program for Internet News & Email” = “Pine is not Elm”
ping = 拟声又 = Packet InterNet Grouper
pirntcap = PRINTer CAPability
popd = POP Directory
pr = pre
printf = PRINT Formatted
ps = Processes Status
pty = pseudo tty
pushd = PUSH Directory
pwd = Print Working Directory
rc = runcom = run command, rc 还是 plan9的 shell
rev = REVerse
rm = ReMove
rn = Read News
roff = RunOFF
rpm = RPM Package Manager = RedHat Package Manager
rsh, rlogin, rvim 中的 r = Remote
rxvt = ouR XVT
seamoneky = 我
sed = Stream EDitor
seq = SEQuence
shar = SHell ARchive
slrn = S-Lang rn
ssh = Secure SHell
ssl = Secure Sockets Layer
stty = Set TTY
su = Substitute User
svn = SubVersioN
tar = Tape ARchive
tcsh = TENEX C shell
tee = T (T 形水管接口)
telnet = TEminaL over Network
termcap = terminal capability
terminfo = terminal information
tex = τ
wc word counter
参考
鸟哥的linux私房菜 第三版