Linux common command

1. What command is used to create a directory? What command is used to create a file?

Answer:
Create a directory: mkdir
Create a file: typically touch, vi can also create a file, in fact, as long as you output to a non-existent file, the file will be created

File permissions modification: chmod

chmod 751 file: Assign read, write, and execute (7) permissions to the owner of the file

         assign read, write, and execute (7) permissions to the file’s group Permission to execute (5)

         assign the permission to execute (1) to other users

2, what commands can be used to view the contents of the file?

Answer:
vi file name#View in edit mode, can be modified
cat file name#show all file contents
more file name#show file contents in pages
less file name #Similar to more, even better, you can turn the page forward.
tail file name#Only view the tail, you can also specify the number of lines

3. Which file to use for moving Order? Which command is used to change the name?
Answer:
mv mv

4. Which command is used to delete a file? What if you need to delete the directory and the files in the directory together? What command is used to delete an empty folder?
Answer:
rm rm -r rmdir

5,

What command is used to count the contents of a file? (Line number, word count, byte count)
Answer:

wc command-c count bytes-l count lines-w count words.

6. What is the use of the Grep command? How to ignore case? How to find the line that does not contain the string?
Answer:
is a powerful text search tool that can search for text using regular expressions and print out the matching lines.
grep [stringSTRING] filename grep [^string] filename

7,

What are the statuses of processes in Linux? In the information displayed by ps, what symbols are used to represent them?
Answer:
(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). Pause state/tracking state: Send a SIGSTOP signal to the process, and it will enter the TASK_STOPPED state in response to the signal; when the process is being tracked, it is in the special state of TASK_TRACED.
“Being tracked” refers to the process being paused and waiting for the tracking process 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), interruptible sleep State: The process in this state is suspended because it is waiting for the occurrence of certain events (such as waiting for socket connection, waiting for semaphore)
(6), zombie state (zombie): the father did not pass the wait series of system calls Will also release the body of the child process (task_struct) by the way
(7), exit status

D Uninterruptible (usually IO)
R is running, or in the queue The process in
S is dormant
T is stopped or tracked
Z zombie process
W enters memory swap (invalid starting from kernel 2.6)
X dead process

8,

Which command is used to view background tasks?

Answer:

job -l

9,

What command is used to terminate the process? What parameters?

Answer:

kill [-s ][program] or kill [-l ]

kill-9 pid

10、

How to check all the signals supported by the system?

Answer:

kill -l

11. What command is used to search for files? What is the format?

Answer:

find

whereis add parameters and file name

locate only add files Name

find searches the disk directly, which is slower.

find / -name “string*”

12. What command can I use to check disk usage? What about free space?

Answer:

df -hl
Filesystem Size Used Avail Use% Mounted on / dev/hda2 45G 19G 24G 44% /
/dev/hda1 494M 19M 450M 4% /boot

13. The definition of du and df, and the difference?

Answer:

du displays the size of the directory or file

df displays the information of the file system where each is located, the default is to display all file systems

14. If a linux novice wants to know the list of all the commands supported by the current system, what should he do?

Answer:

Use the command compgen -c to print out a list of all supported commands.

15. What is the function of the hash command in the bash shell?

Answer:

The linux command’hash’ manages a built-in hash table, which records the complete path of the executed command, and can be printed with this command List the commands you have used and the number of executions.

[[email protected] ~]# hash

hits command

2 /bin/ls

2 /bin /su

16、

Leave a Comment

Your email address will not be published.