快乐的linux命令行

chapter 2

1. 鼠标左键高亮部分文本,鼠标中键粘贴。
2.  日期:date 
3.  月历:cal
4. 磁盘剩余空间:df
5.  空闲内存	:free
6. exit
7. 幕后控制台:ctrl+alt+F1....F6  ; F7退出

chapter 3

1. 当前目录:pwd
2. 切换:cd
3. 列举:ls
4. 绝对路径,以‘/’开始:cd /usr/bin 
5. 相对路径,'.' 表示当前工作目录,'..'表示上一级,;'./'是默认隐含的 cd ./bin 等价于 cd bin
6. cd快捷键:家目录,先前工作目录,用户目录分别为 cd   cd -  cd ~anker
7. '.'开头表示隐藏文件, ls -a 可查看到
8. 文件、命令大小写敏感
9. 符号仅限于".","-""_".

chapter 4

ls
ls /usr
ls ~/usr
ls -l
ls -lt
ls -lt --reverse
ls -a  所有
ls -d  常用ls -ld
ls -F	加指示符显示
ls -h	人可读
ls -l   长格式显示
ls -r   反序
ls -S   文件大小排序
ls -t	修改时间排序
查看文件类型 :file filename 
查看文件:less filename 按q退出

chapter 5

cp
mv
mkdir
rm
ln


# 拷贝所有以'.html'结尾的程序到目标文件路径
cp -u *.html destination

通配符: 
	*
	?
	[characters]
	[!characters]
	[[:class]]
	[:alnum:]
	[:alpha:]
	[:digit:]
	[:lower:]
	[:upper:]

eg.
	*
	g*
	b*.txt
	Data???
	[abc]*
	BACKCUP.[0-9][0-9][0-9]
	[[:upper:]]*
	[![:digit:]]*
	*[[:lower:]123]

mkdir dir1, dir2, dir3

cp item1 imtem2
cp item... directory


cp 
	-a 复制所有
	-i 提示是否重写
	-r 递归遍历
	-u 仅复制不存在文件
	-v 显示操作信息

cp file1 file2

cp -i file1 file2

cp file1 file2 dir1

cp dir1/* dir2

cp -r dir1 dir2

mv item1 item2
mv item... directory

mv 
	-i 提示是否重写
	-u 仅移动目标路径不存在的文件
	-v 显示操作信息

mv file1 file2
mv -i file1 file2
mv file1 file2 dir1
mv dir1 dir2


rm
	-i 提示是否删除
	-r 递归遍历删除
	-f 忽视不存在的文件 不显示提示信息
	-v 显示操作信息

rm file1
rm -i file1
rm -r file1 dir1
rm -rf file1 dir1

# 硬链接
ln file link
# 符合连接
ln -s item link

# 示例游戏
   mkdir playground
   cd playground
   mkdir dir1 dir2
   cp /etc/passwd .
   ls
   cp -v /etc/passwd .
   cp -i /etc/passwd .
   mv passwd fun
   ls
   cat fun
   mv fun dir1
   mv fun dir1/fun dir2
   ls
   tree
   mv dir2/fun .
   ls
   mv fun dir1
   tree
   mv dir2/dir1
   mv dir1/fun
   mv dir1 dir2
   ls
   ls -l dir2
   ls -l dir2/dir1
   tree
   mv dir2/dir1 .
   ls
   mv dir1/fun .
   ls
   ln fun fun-hard
   ln fun dir1/fun-hard
   ln fun dir2.fun-hard
   ls
   tree
   ls -i
   ln -s fun fun-sym
   ls
   ln -s ../fun dir1/fun-sum
   ln -s ../fun dir2/fun-sum
   ls
   tree
   cd ..
   ls
   cd playground
   ls
   ls -l dir1
   ls
   ls dir1
   pwd
   ln -s /Users/anker/playground/fun dir1/fun-sum
   ln -s dir1 dir1-sym
   ls
   ls -l
   rm fun-hard
   ls -h
   ls -l
   rm -i fun
   ls
   rm -i fun
   ls
   ls -l
   ls
   less fum-sym
   rm fum-sym dir1-sym
   rm fun-sym dir1-sym
   ls -l
   cd
   rm -r playground
   ls

chapter 6

# 显示命令类型
type command
type type
type ls
type cp


# 显示位置
which ls
which cd

# 帮助文档
help cd

#部分命令支持 --help选项
mkdir --help

# man显示程序手册页
man program

man ls

man 5 passwd

# 显示适当的命令
apropos floppy

# 显示非常简洁的命令说明
whatis 

info

ps aux|grep info
info coreutils
info -h
cd /usr
ls
cd -
ls
pwd
cd /usr; ls; cd-
cd /usr; ls; cd -
type test
test
type foo

# 指定foo为别名
alias foo='cd /usr; ls; cd -'
foo
type foo
# 删除别名
unalias foo
type foo
type ls
ls
type ls
alias l.='ls -d .* --color=tty'

chapter 7

# >输出重定向到ls-output.out
ls -l /usr/bin &> ls-output.out

#导致ls-output.out被清空
ls -l noteEists > ls-output.out

# 追加在文件最后用 >>
ls ** >> **

#重定向标准输出和错误到ls-output.out
ls -l /bin/usr &> ls-output.out

# /dev/null指‘位存储桶’
ls -l /bin/usr 2> /dev/null

cat
cat text1.txt

#text2的内容被text1覆盖
cat text1.txt > text2.txt
# text1内容追加在text2后
cat text1.txt >> text2.txt
# 拼接成一个文件
cat moive.mpeg.0* > movie.mpeg

#创建文件test.txt
cat > test.txt
# 'you know, I'm just test program cat!'
ctrl+d 结束输入

# 把标准输入重定向到 lazy_dog.txtlazy_dog.txt
cat < lazy_dog.txt

# 管道线
command1 | command2

ls -l /usr/bin | less

# sort充当过滤器
ls -l /usr/bin | sort | less

# uniq删除重复行
ls -l /usr/bin | sort | uniq | less

# 打印行数, 字数,字节数
wc ls-output.txt


ls /bin /usr/bin |sort |uniq| grep zip


tail
head

tail -n 5 text1.txt
head -n 5 test2.txt
ls /usr/bin | tail -n 5

# tee 从 Stdin读取数据,输出到 Stdout中间,
# 在过滤之前保存到文件中
ls /usr/bin | tee ls.txt | grep zip
tee
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

ColaForced

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值