1. What symbol is used for absolute path? What is the current directory and upper directory? What is the main directory? What command is used to switch directories?
a Absolute path: such as /etc/init.d
b current directory and upper directory: ./ ../
c home directory: ~/
d switch directory:cd
2. How to check the current process? How to perform exit? How to check the current path?
a View the current process: ps
b Execute and exit: exit
c View the current path:pwd
3. How to clear the screen? How to exit the current command? How to perform sleep? How to check the current user id? What command is used to view the specified help?
a Clear the screen: clear
b Exit the current command: ctrl+c
Exit completely
c Execute sleep: ctrl+z
Suspend the current process fg Resume the background
d View the current user id: "id": View and display the uid and gid of the currently logged in account, as well as the group and user name
e view designated help: If man adduser
this is full and there are examples; adduser --help
this tells you some common parameters; info adduesr
;
4. What function does the Ls command perform? What parameters can be taken and what is the difference?
a ls
Function to be executed: List the directories and files in the specified directory.
Which parameters and differences: -a
all files, -l
detailed information, including size in bytes, permissions for readable, writable and executable, etc.
5. Establish soft link (shortcut) and hard link commands.
Soft link: ln -s slink source
Hard link:ln link source
6. What command is used for directory creation? What command is used to create a file? What command is used to copy files?
a Create a directory: mkdir
b Create a file: typically touch
, vi
you can also create a file, in fact, as long as you output to a file that does not exist, the file will be created
c Copy files: cp
7. What command is used to modify file permissions? What is the format?
a File permission modification: chmod
The format is as follows:
$ chmod u+x file
add execution permission to the owner of file
$ chmod 751 file
Assign the read, write, and execute (7) permissions to the owner of the file, assign the read and execute (5) permissions to the group where the file is located, and assign the execute (1) permissions to other users
$ chmod u=rwx,g=rx,o=x
Another form of file above
$ chmod =r
file assigns read permissions to all users
$ chmod 444
file Same as above
$ chmod a-wx,a+r
file Same as above
$ chmod -R u+r directory
Recursively assign read permissions to the owners of all files and subdirectories under the directory directory
8. What commands can be used to view file contents?
vi
File name#View in edit mode, can be modified
cat
File name#Display all file contents
more
File name#Display file content in pages
less
File name# is similar to more, and better is that you can page forward
tail
File name#View only the tail, you can also specify the number of lines
head
File name#View only the header, you can also specify the number of lines
9. Feel free to write file commands? How to output a string with spaces, such as "hello world" to the screen?
Write file command:vi
10. Which file is under which folder is the terminal? Which command in which folder is the black hole file?
Terminal: /dev/tty
Black hole:/dev/null
11. Which command is used to move files? Which command is used to change the name?
Move files: mv
rename available:mv
12. Which command is used to copy files? What if you need to copy together with the folder? What if you need a reminder function?
Copy files: cp
copy and folder:cp -r
13. Which command is used to delete files? What if you need to delete the directory and the files in the directory together? What command is used to delete an empty folder?
Delete files: rm
delete directories and files: rm -r
delete empty files:rmdir
14. What kinds of wildcards can be used for commands under Linux? What do they mean?
“?”
Can replace a single character 。 ·
“*”
can replace any number of characters The 。·
square bracket "[charset]" can replace
any single character in the charset set, such as [az], [abABC]
15. What command is used to count the contents of a file? (Line number, number of words, number of bytes)
wc
Command - c
the number of bytes. - l
Count the number of rows. - w
Count the number of words.
16. What is the use of the Grep command? How to ignore case? How to find the rows without the string?
The a Grep
command is a powerful text search tool. It can search for text using regular expressions and print out the matching lines.
b Ignore case: grep [stringSTRING] filename
c Find the line that does not contain the stringgrep [^string] filename
17. What are the statuses of processes in Linux? What symbols are used in the information displayed by ps?
(1) Uninterruptible state: The process is in a sleep state, but the process is uninterruptible at the moment. Uninterruptible means that the process does not respond to asynchronous signals.
(2), the pause state / status tracking: a process to send SIGSTOP
a signal, in response to the signal because it will enter TASK_STOPPED
state; when the process is being tracked, it is in TASK_TRACED
this particular state.
"Being tracked" refers to the process being paused and waiting for the process tracking it to operate on it.
(3) Ready state: the state in the run_queue
queue
(4), the running state: the state in the run_queue
queue
(5), can interrupt sleep: in this state because the process waiting to happen certain events (for example, wait socket
, wait semaphore), and is suspended
(6), zombie
state (zombie): Father did not pass the wait
series system The call will task_struct
also release the body of the child process ( ) by the way
(7) Exit status:
D cannot be interruptedUninterruptible(usually IO)
R is running, or a process in the queue
S is dormant
T stopped or tracked
Z zombie process
W enters memory swap (invalid starting from kernel 2.6)
X dead process
18.How to make a command run in the background?
use &
19. How to use ps to display all processes? How to use ps to view the information of a specified process?
ps -ef (system v 输出)
ps -aux bsd
Format output
ps -ef | grep pid
20. Which command is specifically used to view background tasks?
job -l
21. What command is used to transfer the background task to the foreground for execution? What command is used to execute the stopped background task in the background?
fg
E.g: #jobs [1]+ Running /root/bin/rsync.sh & #fg 1 bg 类似
22. What command is used to terminate the process? What parameters?
kill -9 pid
23. How to check all the signals supported by the system?
kill -l
24. What command is used to search for files? What is the format?
find dir -name "string*"
25. Check who is currently using the host using what command? What command is used to find the terminal information where you are?
w User name; user's machine name or tty number; remote host address; time for the user to log in to the system; idle time (not very useful); time used by the process attached to the tty (terminal) (JCPU time); time used by the current process (PCPU time); The command currently being used by the user.
who
User name, tty
number, time and date, host address
whoami,id -un
The command is used to display the login user name
last
Commands can be used to display the history of a specific user's login system (last jason): user name; tty device number; historical login time and date; logout time and date; total working time.
Find the terminal information where you are located:who am i
26. What command is used to view the list of used commands?
history
27. What command is used to check disk usage space? What about 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 is used to check whether the network is connected?
netstat
29. What command is used to view ip address and interface information?
ifconfig
30. What command is used to view various environment variables?
View all env
view a like home:env $HOME
31. What command is used to specify the command prompt?
\u
Display the current user account,
\h
display the current host name,
\W
only display the current path, the last directory,
\w
display the current absolute path (the current user directory will be replaced by ~),
$PWD
display the current full path,
\$
display the command line'$' or'#' sign
\#
: the first command issued
\d
: On behalf of the date, the format is weekday month date
, for example: "Mon Aug 1"
\t
: Display time is in 24-hour format, such as:: HH:MM:SS \T
Display time is in 12-hour format \A: Display time is in 24-hour format: HH:MM \v
:BASH version information
such asexport PS1='[\u@\h \w\#]\$ '
32. Where do you find the executable file of the search command? How to set and add it?
whereis [-bfmsu][-B <目录>...][-M <目录>...][-S <目录>...][文件...]
Supplementary note: The whereis
instruction will search for eligible files in a specific directory. The strength of these files should belong to the original code, binary files, or help files.
-b 只查找二进制文件。
-B <目录> 只在设置的目录下查找二进制文件。
-f 不显示文件名前的路径名称。
-m 只查找说明文件。
-M <目录> 只在设置的目录下查找说明文件。
-s 只查找原始代码文件。
-S <目录> 只在设置的目录下查找原始代码文件。
-u 查找不包含指定类型的文件。
which 指令会在 PATH 变量指定的路径中,搜索某个系统命令的位置,并且返回第一个搜索结果。
-n 指定文件名长度,指定的长度必须大于或等于所有文件中最长的文件名。
-p 与-n 参数相同,但此处的包括了文件的路径。
-w 指定输出时栏位的宽度。
-V 显示版本信息
33. What command is used to find and execute the command?
which
Only check executable files whereis
only check binaries, documentation, source files, etc.
34. How to alias a command?
alias la='ls -a'
35. The definition of du and df, and the difference?
du
Display the size of a directory or file.
df
Display the information of the file system where each <file> is located. The default is to display all file systems.
(The file system allocates some of the disk blocks to record some of its own data, such as i-nodes, disk distribution maps, indirect blocks, super blocks, etc.
These data are invisible to most user-level programs, usually called Meta Data
. ) du
Command is a user-level programs, it does not consider Meta Data
, and df
command the view of the file system disk allocation
map and consider Meta Data
.
df
The command obtains the real file system data, and the du
command only looks at part of the file system.
36.awk detailed explanation.
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