5 linux interview questions every day (first day)

(1) Create a file? Create a directory? Batch creation?

Create file: touch file name

Create files in batch: touch file name file name...

➜ test touch a

➜ test ls

a

➜ test touch b c

➜ test ls

a b c

Create a directory: mkdir directory name

Batch create directories: mkdir directory name directory name...

➜ test mkdir aa

➜ test mkdir bb cc

➜ test ls

a aa b bb c cc

➜ test ls -F

a aa/ b bb/ c cc/

(2) Delete files? Force delete? Recursive deletion?

Syntax: rm destination

-i ask whether to delete, -r delete recursively, -f force delete.

rm cannot delete directories with files, it needs to be deleted recursively.

➜ xktest rm jdk

rm: jdk: is a directory

➜ xktest rm -r jdk

➜ xktest ls

rm -i asks to delete, it is recommended that you usually delete the multi-i -i, and then delete it after confirming it.

➜ xktest touch tomcat

➜ xktest rm -i tomcat

remove tomcat? n

rm -rf will delete it directly, there is no warning message, it must be used with caution

(3) How to view the files in the directory? Distinguish which are files and which are directories? Recursive search?

The ls command will display the files and directories in the current directory in the most basic form:

➜ local ls

Caskroom Frameworks bin go lib sbin var

Cellar Homebrew etc include opt share

It can be seen that the default is displayed in alphabetical order

Generally speaking, the ls command displays different colors to distinguish different file types. If the color plug-in is not installed, you can use ls -F to distinguish which are directories (directories with /) and which are files (files without /)


ls -R recursively displays the files in the directory and subdirectories. The more directories, the more output.

(4) How to switch directories?

Syntax: cd destination

destination: relative file path or absolute file path

You can jump to any directory that exists.

(5) Lost, where is my current location?

pwd displays the current directory

[root@iz2ze76ybn73dvwmdij06zz local]# pwd

/usr/local

每天为大家更新5道linux面试题,欢迎大家点赞、评论、收藏、留言。


Guess you like

Origin blog.51cto.com/11868421/2664613