命令行基礎

1.ls

List directory contents.

- List files one per line:

ls -1

- List all files, including hidden files:

ls -a

- Long format list (permissions, ownership, size and modification date) of all files:

ls -la

- Long format list with size displayed using human readable units (KB, MB, GB):

ls -lh

- Long format list sorted by size (descending):

ls -lS

- Long format list of all files, sorted by modification date (oldest first):

ls -ltr

2.cat

Print and concatenate files.

- Print the contents of a file to the standard output:

cat file

- Concatenate several files into the target file:

cat file1 file2 > target_file

- Append several files into the target file:

cat file1 file2 >> target_file

- Number all output lines:

cat -n file

3. mv

Move or rename files and directories.

- Move files in arbitrary locations:

mv source target

- Do not prompt for confirmation before overwriting existing files:

mv -f source target

- Do not prompt for confirmation before overwriting existing files but write to standard error before overriding:

mv -fi source target

- Move files in verbose mode, showing files after they are moved:

mv -v source target

4. touch

Change a file access and modification times (atime, mtime).

- Create a new empty file(s) or change the times for existing file(s) to current time:

touch filename

- Set the times on a file to a specific date and time:

touch -t YYYYMMDDHHMM.SS filename

- Use the times from a file to set the times on a second file:

touch -r filename filename2

?著作權歸作者所有,轉載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容