Classic and basic knowledge of Linux command -1

1. What is the absolute path indicated by the symbol? The current directory, parent directory is represented by what? Home directory is represented by what? Change directory what order?

		绝对路径:如/etc/init.d
		当前目录和上层目录:./  ../
		主目录:~/
		切换目录:cd

2. how to view the current process? How an exit? How to view the current path?

		查看当前进程:ps
		执行退出:exit
		查看当前路径:pwd

3. how clear the screen? How to exit the current command? How to perform sleep? How to view the current user id? View help specify what order?

	清屏:clear
	退出当前命令:ctrl+c 彻底退出
	执行睡眠 :ctrl+z 挂起当前进程fg 恢复后台
	查看当前用户 id:”id“:查看显示目前登陆账户的 uid 和 gid 及所属分组及用户名
	查看指定帮助:如 man adduser 这个很全 而且有例子;adduser --help 这个告诉你一些常用参数;info adduesr;

4. Ls command performs what function? Which parameter can take, what's the difference?

	ls 执行的功能:列出指定目录中的目录,以及文件哪些参数以及区别:a 所有文件l 详细信息,包括大小字节数,可读可写可执行的权限等

5. Establish a soft link (shortcut), and hard links command.

	软链接:ln -s slink source
	硬链接:ln link source

6. Create a directory what order? Create a file what order? Copy the file what order?

创建目录:mkdir
创建文件:典型的如 touch,vi 也可以创建文件,其实只要向一个不存在的文件输出,都会创建文件
复制文件:cp 7. 文件权限修改用什么命令?格式是怎么样的?
文件权限修改:chmod
格式如下:
	$ chmod u+x file 给 file 的属主增加执行权限
	$ chmod 751 file 给 file 的属主分配读、写、执行(7)的权限,给 file 的所在组分配读、执行(5)的权限,给其他用户分配执行(1)的权限
	$ chmod u=rwx,g=rx,o=x file 上例的另一种形式
	$ chmod =r file 为所有用户分配读权限
	$ chmod 444 file 同上例
	$ chmod a-wx,a+r file同上例
	$ chmod -R u+r directory 递归地给 directory 目录下所有文件和子目录的属主分配读的权限

7. View the contents of the file have what command?

vi 文件名 #编辑方式查看,可修改
cat 文件名 #显示全部文件内容
more 文件名 #分页显示文件内容
less 文件名 #与 more 相似,更好的是可以往前翻页
tail 文件名 #仅查看尾部,还可以指定行数
head 文件名 #仅查看头部,还可以指定行数

8. free to write file commands? How the string with spaces to the screen output, such as "hello world"?

写文件命令:vi
向屏幕输出带空格的字符串:echo hello world

9. terminal which file is which folder? Black hole which command file which folder?

终端  /dev/tty	
黑洞文件  /dev/null

10. Move files which command? Which changed its name to command?

mv mv

11. Which command to copy files? If you need to copy a folder along with it? If you need prompts it?

cp cp -r  ????

12. Delete the file which command? If you need even directories and directory delete a file it? Delete empty folders what order?

rm rm -r rmdir

13. Linux command, which has several wildcards that can be used? What do they all mean?

“?”可替代单个字符。
“*”可替代任意多个字符。
方括号“[charset]”可替代 charset 集中的任何单个字符,如[a-z],[abABC]

15. What orders the contents of a file of statistics? (Row number, number of words, number of bytes)

wc 命令 - c 统计字节数 - l 统计行数 - w 统计字数。

16. Grep command what is the use? How to ignore case? How to find free line of the string?

是一种强大的文本搜索工具,它能使用正则表达式搜索文本,并把匹 配的行打印出来。
grep [stringSTRING] filename grep [^string] filename

17. Linux in the process, which has several state? Ps displayed in the message, respectively, what notation?

(1)、不可中断状态:进程处于睡眠状态,但是此刻进程是不可中断的。不可中断, 指进程不响应异步信号。
(2)、暂停状态/跟踪状态:向进程发送一个 SIGSTOP 信号,它就会因响应该信号 而进入 TASK_STOPPED 状态;当进程正在被跟踪时,它处于 TASK_TRACED 这个特殊的状态。
“正在被跟踪”指的是进程暂停下来,等待跟踪它的进程对它进行操作。
(3)、就绪状态:在 run_queue 队列里的状态
(4)、运行状态:在 run_queue 队列里的状态
(5)、可中断睡眠状态:处于这个状态的进程因为等待某某事件的发生(比如等待 socket 连接、等待信号量),而被挂起
(6)、zombie 状态(僵尸):父亲没有通过 wait 系列的系统调用会顺便将子进程的尸体(task_struct)也释放掉
(7)、退出状态

	D 不可中断 Uninterruptible(usually IO)
	R 正在运行,或在队列中的进程
	S 处于休眠状态
	T 停止或被追踪
	Z 僵尸进程
	W 进入内存交换(从内核 2.6 开始无效)
	X 死掉的进程

18. how to make a command to run in the background?

一般都是使用 & 在命令结尾来让程序自动运行。(命令后可以不追加空格)

19. The use ps how to display all the processes? Ps to see how the use of the specified process information?

ps -ef (system v 输出) 
ps -aux bsd 格式输出
ps -ef | grep pid

20. Which command is designed to view the background tasks?

job -l

21. The background to the foreground task performed using what order? Background task to stop what order to implement in the background?

把后台任务调到前台执行 fg
把停下的后台任务在后台执行起来 bg

22. The termination process what order? With what parameters?

kill [-s <信息名称或编号>][程序] 或 kill [-l <信息编号>] 
kill-9 pid

23. how to view the system supports all the signals?

kill -l

24. Search for files what order? Format is kind of how?

find <指定目录> <指定条件> <指定动作>
whereis 加参数与文件名
locate 只加文件名
find 直接搜索磁盘,较慢。
find / -name "string*"

25. See who's currently in use by the host what order? Find information terminal where their what order?

查找自己所在的终端信息:who am i
查看当前谁在使用该主机:who

26. What command is used to view the list of commands?

history

27. What command to view disk usage? Free space?

df -hl
文件系统 容量 已用 可用 已用% 挂载点
Filesystem Size Used Avail Use% Mounted on /dev/hda2 45G 19G 24G 44% /
/dev/hda1 494M 19M 450M 4% /boot

28. What command to see whether network connectivity?

netstat

29. What command to view the ip address and interface information?

ifconfig

30. In view of various types of environment variables, what order?

查看所有 env
查看某个,如 home:env $HOME

31. What command specified by the command prompt?

\u:显示当前用户账号
\h:显示当前主机名
\W:只显示当前路径最后一个目录
\w:显示当前绝对路径(当前用户目录会以~代替)
$PWD:显示当前全路径
\$:显示命令行’$'或者’#'符号
\#:下达的第几个命令
\d:代表日期,格式为week day month date,例如:"MonAug1"
\t:显示时间为24小时格式,如:HH:MM:SS
\T:显示时间为12小时格式
\A:显示时间为24小时格式:HH:MM
\v:BASH的版本信息 如export PS1=’[\u@\h\w\#]\$‘

32. Find command executable file is going to find? How to set it up and add?

whereis [-bfmsu][-B <目录>...][-M <目录>...][-S <目录>...][文件...]
补充说明:whereis 指令会在特定目录中查找符合条件的文件。这些文件的烈性应属于原始代码,二进制文件,或是帮助文件。
-b   只查找二进制文件。
-B   <目录> 只在设置的目录下查找二进制文件。-f 不显示文件名前的路径名称。
-m   只查找说明文件。
-M   <目录> 只在设置的目录下查找说明文件。-s 只查找原始代码文件。
-S   <目录> 只在设置的目录下查找原始代码文件。-u 查找不包含指定类型的文件。
which 指令会在 PATH 变量指定的路径中,搜索某个系统命令的位置,并且返回第一个搜索结果。
-n   指定文件名长度,指定的长度必须大于或等于所有文件中最长的文件名。
-p   与-n 参数相同,但此处的包括了文件的路径。-w 指定输出时栏位的宽度。
-V   显示版本信息

33. Find execute commands through what order?

which 只能查可执行文件
whereis 只能查二进制文件、说明文档,源文件等

34. how to command alias?

alias la='ls -a'

35. du and df is defined, and the difference?

du 显示目录或文件的大小
df 显示每个<文件>所在的文件系统的信息,默认是显示所有文件系统。
(文件系统分配其中的一些磁盘块用来记录它自身的一些数据,如 i 节点,磁盘分布图,间接块,超级块等。这些数据对大多数用户级的程序来说是不可见的,通常称为 Meta Data。) du 命令是用户级的程序,它不考虑 Meta Data,而 df 命令则查看文件系统的磁盘分配图并考虑 Meta Data。
df 命令获得真正的文件系统数据,而 du 命令只查看文件系统的部分情况。

36. awk explain.

awk '{pattern + action}' {filenames}
#cat /etc/passwd |awk -F ':' '{print $1"\t"$7}' //-F 的意思是以':'分隔 root /bin/bash
daemon /bin/sh 搜索/etc/passwd 有 root 关键字的所有行
#awk -F: '/root/' /etc/passwd root:x:0:0:root:/root:/bin/bash

37. When you need to bind a command or macro keys, how should I do it?

可以使用bind命令,bind可以很方便地在shell中实现宏或按键的绑定。
在进行按键绑定的时候,我们需要先获取到绑定按键对应的字符序列。
比如获取F12的字符序列获取方法如下:先按下Ctrl+V,然后按下F12 .我们就可以得到F12的字符序列 ^[[24~。
接着使用bind进行绑定。
[root@localhost ~]# bind ‘”\e[24~":"date"'
注意:相同的按键在不同的终端或终端模拟器下可能会产生不同的字符序列。
【附】也可以使用showkey -a命令查看按键对应的字符序列。

38. If a list of all the commands novice wants to know the current system supports linux, how he needs to do?

使用命令compgen ­-c,可以打印出所有支持的命令列表。
[root@localhost ~]$ compgen -c

39. If you want assistant to print out the current directory stack, how would you advise him to do?

使用Linux 命令dirs可以将当前的目录栈打印出来。
[root@localhost ~]# dirs
/usr/share/X11
【附】:目录栈通过pushd popd 来操作。

40. Your system There are many tasks that are running, restart the machine without conditions, is there any way you can put all the running processes to remove it?

使用linux命令 ’disown -r ’可以将所有正在运行的进程移除。

41. bash shell hash command in what role?

linux命令’hash’管理着一个内置的哈希表,记录了已执行过的命令的完整路径, 用该命令可以打印出你所使用过的命令以及执行的次数。
[root@localhost ~]# hash
hits command
2 /bin/ls
2 /bin/su

42. How to view the contents of a page by page large file it?

通过管道将命令”cat file_name.txt” 和 ’more’ 连接在一起可以实现这个需要.
[root@localhost ~]# cat file_name.txt | more

43. How to view a summary of the usage of a linux command? Suppose you happened to see a command you've never seen before in the / bin directory, how do you know its role and usage of it?

答案:
使用命令whatis 可以先出显示出这个命令的用法简要,比如,你可以使用whatis zcat 去查看‘zcat’的介绍以及使用简要。
[root@localhost ~]# whatis zcat
zcat [gzip] (1) – compress or expand files

44. Which one command to view the disk space quota own file system?

使用命令repquota 能够显示出一个文件系统的配额信息
【附】只有root用户才能够查看其它用户的配额。
Published 18 original articles · won praise 16 · views 20000 +

Guess you like

Origin blog.csdn.net/weixin_44569012/article/details/100900242