Linux command tutorial

[color=red][b]Listing files and directories[/b][/color]
[b][color=green]ls[/color][/b]
ls -a 列出包含隐藏文件

[color=red][b]Making Directories[/b][/color]
[color=green][b]mkdir[/b][/color]
mkdir cc

[color=red][b]Changing to a different directory[/b][/color]
[color=green][b]cd[/b][/color]
cd cc

[color=red][b]The directories . and ..[/b][/color]
[color=green][b]. the current directory
.. the parrent directory[/b][/color]
cd .. change to the parent directory

[color=red][b]Pathnames[/b][/color]
[b][color=green]pwd print wording directory[/color][/b]
the top-level root directory called " / "
your home directory called "~" 当前用户的根目录

[color=red][b]Copying Files[/b][/color]
[b][color=green]cp[/color][/b]
cp file1 file2 is the command which makes a copy of file1 in the current working directory and calls it file2
cp /vol/examples/tutorial/science.txt .
The above command means copy the file science.txt to the current directory, keeping the name the same.

[color=red][b]Moving files[/b][/color]
[color=green][b]mv[/b][/color]
mv file1 file2 moves (or renames) file1 to file2

[color=green][b][color=red][b]Removing files and directories[/b][/color]
rm (remove), rmdir (remove directory)[/b][/color]

[color=red][b]Displaying the contents of a file on the screen[/b][/color]
[color=green][b]clear (clear screen)[/b][/color]

[color=green][b]cat (concatenate)[/b][/color]
The command cat can be used to display the contents of a file on the screen.
% cat science.txt

[color=green][b]less[/b][/color]
The command less writes the contents of a file onto the screen a page at a time.
% less science.txt
Press the [color=green][b][space-bar][/b][/color] if you want to see another page, and type [color=green][b][q][/b][/color] if you want to quit reading. As you can see, less is used in preference to cat for long files.

[b][color=green]head[/color][/b]
The head command writes the first ten lines of a file to the screen.
% head science.txt
% head -5 science.txt

[color=green][b]tail[/b][/color]
The tail command writes the last ten lines of a file to the screen.
% tail science.txt

[color=red][b]Searching the contents of a file[/b][/color]
[color=green][b]Simple searching using less[/b][/color]
% less science.txt
then, still in less, type a forward slash [/] followed by the word to search
/science
As you can see, less finds and [color=blue]highlights[/color] the keyword. Type [n] to search for the next occurrence of the word.

[color=green][b]grep[/b][/color]
% grep science science.txt
[b][color=blue]The grep command is case sensitive[/color][/b]
To ignore upper/lower case distinctions, use the -i option, i.e. type
% grep -i science science.txt
To search for a phrase or pattern, you must enclose it in single quotes (the apostrophe symbol). For example to search for spinning top, type
% grep -i 'spinning top' science.txt
Some of the other options of grep are:
-v display those lines that do NOT match 不匹配的
-n precede each matching line with the line number 加行号
-c print only the total count of matched lines 匹配个数

[color=green][b]wc (word count)[/b][/color]
A handy little utility is the wc command, short for word count. To do a word count on science.txt, type
% wc -w science.txt
To find out how many lines the file has, type
% wc -l science.txt

[color=red][b]Redirecting the Output [/b][/color]
[color=green][b]>[/b][/color]
% cat > list1
输入cat,不输人参数,然后回车,会将用户输入回显,这个命令是将用户输入重定向到list1

[color=green][b]Appending to a file[/b][/color]
% cat >> list1
% cat list1 list2 > biglist join two file to biglist
% cat list1 list2 > biglist

[color=red][b]Redirecting the Input[/b][/color]
[color=green][b]<[/b][/color]
% sort < biglist 从biglist中读入数据进行排序
% sort < biglist > slist 从biglist中读入数据进行排序,结果输出到slist

[color=red][b]Pipes[/b][/color]
% who > names.txt
% sort < names.txt
% who | sort who的输出作为sort的输入

[color=red][b]Wildcards[/b][/color]
[color=green][b]The * wildcard[/b][/color]
% ls list*
% ls *list
*表示任意个
[color=green][b]The ? wildcard[/b][/color]
% ls ?list
?表示一个字符

[color=red][b]Filename conventions[/b][/color]
In naming files, characters with special meanings such as / * & % , should be avoided.避免特殊字符
File names conventionally start with a lower-case letter, and may end with a dot followed by a group of letters indicating the contents of the file.小写字母开头,后缀文件类型
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值