第一章:实验 访问命令行
1.改本用户密码
[student@localhost /]$ passwd
Changing password for user student.
Changing password for student.
(current) UNIX password:
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
[student@localhost /]$
2.显示当前的时间和日期
[student@localhost /]$ date
Sat Jul 25 16:09:42 CST 2015
[student@localhost /]$
3.以下列格式显示时间:HH:MM:SS A/PM
[student@localhost /]$ date +%r
04:13:40 PM
[student@localhost /]$
4.clean-binary-files的文件类型是什么?可否被人读取?
[student@localhost /]$ ll /usr/bin/clean-binary-files
-rwxr-xr-x. 1 root root 188175 Jul 25 16:06 /usr/bin/clean-binary-files
[student@localhost /]$
从上面的结果可得:类型:文件;其他人那里有r的权限,因此可被人读取
6.使用wc命令和bach快捷方式显示clean-binary-files的大小
[student@localhost /]$ wc /usr/bin/clean-binary-files
3373 27276 188175 /usr/bin/clean-binary-files
[student@localhost /]$
7.显示clean-binary-files的前10行
[student@localhost ~]$ cat -n /usr/bin/clean-binary-files | head -10
1 #!/bin/sh
2 #
3 # Script to clean binary files.
4 #
5 # JPackage Project <http://www.jpackage.org/>
6 #
7 # $Id: clean-binary-files,v 1.1 2006/09/19 19:39:37 fnasser Exp $
8
9 # Import java functions
10 [ -r "/usr/share/java-utils/java-functions" ] \
[student@localhost ~]$
8.显示clean-binary-files的尾10行
[student@localhost ~]$ cat -n /usr/bin/clean-binary-files | tail -10
3364 -rwxr-xr-x. 1 root root 100432 Jan 28 2014 zipcloak
3365 -rwxr-xr-x. 1 root root 48451 Dec 29 2013 zipdetails
3366 -rwxr-xr-x. 1 root root 2953 Oct 11 2008 zipgrep
3367 -rwxr-xr-x. 2 root root 177152 Jan 28 2014 zipinfo
3368 -rwxr-xr-x. 1 root root 95960 Jan 28 2014 zipnote
3369 -rwxr-xr-x. 1 root root 100064 Jan 28 2014 zipsplit
3370 -rwxr-xr-x. 1 root root 2041 Jan 25 2014 zless
3371 -rwxr-xr-x. 1 root root 2859 Jan 25 2014 zmore
3372 -rwxr-xr-x. 1 root root 5343 Jan 25 2014 znew
3373 lrwxrwxrwx. 1 root root 6 Jul 25 04:16 zsoelim -> soelim
[student@localhost ~]$
9.重复上一命令,但使用-n 20 选项来显示文件的最后20行
[student@localhost ~]$ cat -n /usr/bin/clean-binary-files | tail -n 20
3354 -rwxr-xr-x. 1 root root 1760 Jan 25 2014 zcmp
3355 -rwxr-xr-x. 1 root root 5768 Jan 25 2014 zdiff
3356 -rwxr-xr-x. 1 root root 123 Jan 25 2014 zegrep
3357 -rwxr-xr-x. 1 root root 11344 Feb 26 2014 zeisstopnm
3358 -rwxr-xr-x. 1 root root 1118 Dec 29 2013 zenheiset
3359 -rwxr-xr-x. 1 root root 98696 Jan 28 2014 zenity
3360 -rwxr-xr-x. 1 root root 123 Jan 25 2014 zfgrep
3361 -rwxr-xr-x. 1 root root 2140 Jan 25 2014 zforce
3362 -rwxr-xr-x. 1 root root 5916 Jan 25 2014 zgrep
3363 -rwxr-xr-x. 1 root root 215792 Jan 28 2014 zip
3364 -rwxr-xr-x. 1 root root 100432 Jan 28 2014 zipcloak
3365 -rwxr-xr-x. 1 root root 48451 Dec 29 2013 zipdetails
3366 -rwxr-xr-x. 1 root root 2953 Oct 11 2008 zipgrep
3367 -rwxr-xr-x. 2 root root 177152 Jan 28 2014 zipinfo
3368 -rwxr-xr-x. 1 root root 95960 Jan 28 2014 zipnote
3369 -rwxr-xr-x. 1 root root 100064 Jan 28 2014 zipsplit
3370 -rwxr-xr-x. 1 root root 2041 Jan 25 2014 zless
3371 -rwxr-xr-x. 1 root root 2859 Jan 25 2014 zmore
3372 -rwxr-xr-x. 1 root root 5343 Jan 25 2014 znew
3373 lrwxrwxrwx. 1 root root 6 Jul 25 04:16 zsoelim -> soelim
[student@localhost ~]$
10.不带参数执行date
[student@localhost ~]$ date
Sat Jul 25 16:34:44 CST 2015
[student@localhost ~]$
11.使用bash历史记录仅显示时间
[student@localhost ~]$ history
1 pwd
2 cd /
3 pwd
4 date
5 passwd
6 date --help
7 date +%r
8 ll /usr/bin/clean-binary-files
9 wc /usr/bin/clean-binary-files
10 head -n 10 /usr/bin/clean-binary-files
11 head -n10 /usr/bin/clean-binary-files
12 hread -n10 /usr/bin/clean-binary-files
13 head --help
14 hread /usr/bin/clean-binary-files
15 cat -n | head /usr/bin/clean-binary-files
16 cat /usr/bin/clean-binary-files
17 more /usr/bin/clean-binary-files
18 cat -n | head /usr/bin/clean-binary-files
19 cat -n10 | head /usr/bin/clean-binary-files
20 cat -n 10 | head /usr/bin/clean-binary-files
21 cat --help\
22 cat --help
23 cat -n | head /usr/bin/clean-binary-files
24 ll
25 echo abc > a
26 touch a
27 ll
28 ll > a
29 ll >> a
30 cd /home/student/
31 ll > a
32 ll
33 cat a
34 ll
35 cat a
36 more a
37 ll
38 ll -al
39 vim a
40 ll
41 ll -al >a
42 ll
43 cat a
44 cat -n a
45 cat -n /usr/bin/clean-binary-files
46 cat -n /usr/bin/clean-binary-files | head 10
47 cat -n10 /usr/bin/clean-binary-files | head
48 cat -n10 /usr/bin/clean-binary-files
49 cat -n 10 /usr/bin/clean-binary-files
50 cat -n /usr/bin/clean-binary-files | head -10
51 cat -n /usr/bin/clean-binary-files | tail -10
52 cat -n /usr/bin/clean-binary-files | tail -20
53 cat -n /usr/bin/clean-binary-files | tail -n 20
54 cat -n /usr/bin/clean-binary-files | tail -n 2
55 history
56 tail /usr/bin/clean-binary-files
57 tail -n 20 /usr/bin/clean-binary-files
58 date
59 history
[student@localhost ~]$ !7
date +%r
04:37:04 PM
[student@localhost ~]$
版权声明:本文为博主原创文章,未经博主允许不得转载