Jiakuang He

Some Frequently Used Linux Command

man

used to check for description and arguments for the command

Example

man ls

image-20230320160357131

ls

list directories and files contents

Example

ls

image-20230320160248696

-l

use a long listing format

Example

ls -l

image-20230320160304809

date

Exanple

date

image-20230320160630256

vi

VI is an editor to edit the file content.

Example

vi a.txt

You need to make sure you have a.txt file. If you haven’t, you need to create it first.

You only need to execute command first time.

touch a.txt

mode

Normal Mode

When you use vi to open/edit the file, you enter the normal mode.

Press down esc in any mode (on the left upper conner, one key) command to go back to the Normal Mode.

Insert Mode

If you want to edit the file, you need to use the Insert Mode.

Use i to enter the Insert Mode.

Command-line or Cmdline mode

If you want to use some command, you need to use in this mode.

use : to go the command-line mode.

quit the vi :q

write and quit :wq

quit without save :q! (If you edit anything after you use insert mode, you don’t want to save it)

If you edit anything in the vi, and use the :q, the vi command will give you a warning.

image-20230320162536569

image-20230320162240694

Untitled Diagram.drawio (1)

img

References:

vi - Wikipedia

vi-vim-cheat-sheet.gif (1024×724) (viemu.com)

Vim (text editor) - Wikipedia

rm

abbr: ReMove

used to remove the file or directory

rm THE_FILE_YOU_WANT_TO_REMOVE

Example:

touch a.txt
rm a.txt

pwd

Print Working Directory

image-20230320161043117

whoami

image-20230320160742548

cd

Change Directory

Example

cd Desktop

Use ls to check what directory you have first.

image-20230320160942841

wget

wget https://upload.wikimedia.org/wikipedia/commons/8/80/Cowsay_Typical_Output.png

passwd

passwd THE_USERNAME_WE_WANT_TO_EDIT_THE_PASSWORD

Example

passwd root

Some Playful Command

fortune

image-20230320165121218

cowsay

Welcome to join AIClub is the content you want to let the cow say.

cowsay Welcome to join AIClub

image-20230320165012405

sl

image-20230320164626121