linux命令tab补全,linux的一些快捷键:tab=补全

本文介绍了Linux终端中的常用命令如ls的高级用法ls -h, man手册的帮助系统及其操作,以及alias设置、du用于文件夹大小查看和touch更新时间的功能。还提到了查看文件属性、定位文件位置、wc统计文件内容等技巧。
摘要由CSDN通过智能技术生成

ctrl + l - 清屏,类似 clear 命令

ctrl + r - 查找历史命令 ctrl+c=终止

ctrl+k=删除此处至末尾所有内容

ctrl+u=删除此处至开始所有内容

linux中的帮助命令:man 、 info 、 --help

[root@localhost ~]# man ls

Cannot open the message catalog "man" for locale

"zh_CN.UTF-8"

(NLSPATH="")

Formatting page, please wait...

LS(1) User

Commands LS(1)

NAME

ls - list directory contents

SYNOPSIS

ls [OPTION]... [FILE]...

[root@localhost ~]# info ls

File: coreutils.info, Node: ls

invocation, Next: dir

invocation, Up: Directo\

ry listing

10.1 `ls': List directory contents

==================================

The `ls' program lists information about files (of any

type, including

directories). Options and file arguments can be

intermixed

arbitrarily, as usual.

[root@localhost ~]# ls --help

用法:ls [选项]... [文件]...

List information about the FILEs (the current directory by

default).

Sort entries alphabetically if none of -cftuvSUX nor

--sort.

长选项必须用的参数在使用短选项时也是必须的。

-a,

--all 不隐藏任何以 . 字符开始的项目

-A,

--almost-all 列出除了 . 及 .. 以外的任何项目

--author 和 -l 同时使用时列出每个文件的作者

-b,

--escape 以八进制溢出序列表示不可打印的字符

我个人还是比较喜欢man这个命令的,有问题就男人一把。对于--help出现的文档是中文的,英文不好的朋友可以借鉴这个,不过不是每个命令都有中文帮助的。

退出帮助的话,按快捷键q

昨天讲解ls的时候,丢了一个比较实用的命令,今天冯老师补充了一下,ll

–h,这个命令可以使文件大小显示更容易查看

[root@localhost ~]# ll -h

总计 76K

-rw------- 1 root root 963 06-28 08:47

anaconda-ks.cfg

drwxr-xr-x 2 root root 4.0K 06-28 08:54 Desktop

-rw-r--r-- 1 root root 35K 06-28 08:47

install.log

-rw-r--r-- 1 root root 4.5K 06-28 08:44 install.log.syslog

drwxr-xr-x 2 root root 4.0K 07-12 23:55 nihao

cd ~用户名 进入该用户的家目录中

[root@localhost wl]# pwd

/home/wl

[root@localhost wl]# cd ~wl

[root@localhost wl]# pwd

/home/wl

alias和unalias设置和取消命令的别名

[root@localhost ~]# alias l=ls

[root@localhost ~]# l

anaconda-ks.cfg Desktop install.log install.log.syslog nihao

[root@localhost ~]# ls

anaconda-ks.cfg Desktop install.log install.log.syslog nihao

[root@localhost ~]# alias

alias cp='cp -i'

alias l='ls'

alias l.='ls -d .* --color=tty'

alias ll='ls -l --color=tty'

alias ls='ls --color=tty'

alias mv='mv -i'

alias rm='rm -i'

alias which='alias | /usr/bin/which --tty-only --read-alias

--show-dot --show-tilde'

[root@localhost ~]# unalias l

[root@localhost ~]# alias

alias cp='cp -i'

alias l.='ls -d .* --color=tty'

alias ll='ls -l --color=tty'

alias ls='ls --color=tty'

alias mv='mv -i'

alias rm='rm -i'

alias which='alias | /usr/bin/which --tty-only --read-alias

--show-dot --show-tilde'

[root@localhost ~]#

ls可以显示文件的大小,但是不能准确显示目录的大小,而du -sh则可以准确统计目录、文件的大小

[root@localhost ~]# ll -h

总计 76K

-rw------- 1 root root 963 06-28 08:47

anaconda-ks.cfg

drwxr-xr-x 2 root root 4.0K 06-28 08:54 Desktop

-rw-r--r-- 1 root root 35K 06-28 08:47

install.log

-rw-r--r-- 1 root root 4.5K 06-28 08:44 install.log.syslog

drwxr-xr-x 2 root root 4.0K 07-12 23:55 nihao

[root@localhost ~]# du -sh Desktop/

8.0K Desktop/

[root@localhost ~]# du -sh install.log

40K install.log

[root@localhost ~]# du -sh

2.7M .

touch还有一个功能,可以更新文件的时间,当然参数还有很多,这里只说一个

[root@localhost ~]# ll

总计 76

-rw------- 1 root root 963

06-28 08:47 anaconda-ks.cfg

drwxr-xr-x 2 root root 4096 06-28 08:54

Desktop

-rw-r--r-- 1 root root 35661 06-28 08:47 install.log

-rw-r--r-- 1 root root 4575 06-28 08:44

install.log.syslog

drwxr-xr-x 2 root root 4096 07-12 23:55

nihao

[root@localhost ~]# touch install.log

[root@localhost ~]# ll

总计 76

-rw------- 1 root root 963

06-28 08:47 anaconda-ks.cfg

drwxr-xr-x 2 root root 4096 06-28 08:54

Desktop

-rw-r--r-- 1 root root 35661 07-13 23:52 install.log

-rw-r--r-- 1 root root 4575 06-28 08:44

install.log.syslog

drwxr-xr-x 2 root root 4096 07-12 23:55

nihao

file查看文件属性

[root@localhost ~]# file test.txt

test.txt: ASCII text

[root@localhost ~]# file /etc/passwd

/etc/passwd: ASCII text

whereis定位文件位置命令

[root@localhost ~]# whereis test.txt

test: /usr/bin/test /usr/share/man/man1/test.1.gz

/usr/share/man/man1p/test.1p.gz

[root@localhost ~]# whereis ls

ls: /bin/ls /usr/share/man/man1/ls.1.gz

/usr/share/man/man1p/ls.1p.gz

wc统计指定文件中的字节数、字数、行数, 并将统计结果显示输出

[root@localhost ~]# wc -l test.txt

1 test.txt

[root@localhost ~]# wc -c test.txt

12 test.txt

[root@localhost ~]# wc -w test.txt

2 test.txt

[root@localhost ~]#

用户配置文件:~/.bashrc ~/.bash_profile ~/.bash_logout

全局配置文件:/etc/profile /etc/bashrc

这几个文件,我就不在这里讨论了,我打算明天早上早点起来独立一篇文章专门讲。另外vi由于篇幅比较大,所以说明天可能的话,也于明天独立一篇文章出来。现在时间还是比较紧的,我的效率应该好好提高一点。

history 查看命令的历史记录

[root@localhost ~]# history

1 clear

2 info ls

3 ls -h

4 clear

5 ll -h

6 clear

7 cd ~wl

8 clear

9 pwd

10 cd

~wl

11 pwd

12 cd

13 clear

history –c 清除命令的历史记录

[root@localhost ~]# history

1 clear

2 info ls

3 ls -h

4 clear

5 ll -h

6 clear

7 cd ~wl

8 clear

9 pwd

10 cd ~wl

11 pwd

12 cd

13 clear

[root@localhost ~]# history -c

[root@localhost ~]# history

1 history

另外有个快捷键,ctrl+r可以查找历史命令

which 查找文件命令

[root@localhost ~]# which

ls

alias ls='ls

--color=tty'

/bin/ls

[root@localhost ~]# which

passwd

/usr/bin/passwd

[root@localhost ~]# which

useradd

/usr/sbin/useradd

passwd 修改用户密码

[root@localhost ~]#

passwd

Changing password for user

root.

New UNIX password:

Retype new UNIX

password:

passwd: all authentication tokens

updated successfully.

[root@localhost ~]# passwd

wl

Changing password for user

wl.

New UNIX password:

BAD PASSWORD: it is based on a

dictionary word

Retype new UNIX

password:

passwd: all authentication tokens

updated successfully.

passwd不加用户名,修改的是当前用户的密码,加了用户名就是修改指定用户的密码。

[root@localhost ~]# passwd -l

wl 锁住用户

Locking password for user

wl.

passwd: Success

[root@localhost ~]# passwd -S

wl 查看账户状态

wl LK 2011-07-13 0 99999 7 -1

(Password locked.)

[root@localhost ~]# passwd -u

wl 给用户解锁

Unlocking password for user

wl.

passwd: Success.

[root@localhost ~]# passwd -S

wl

wl PS 2011-07-13 0 99999 7 -1

(Password set, MD5 crypt.)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值