TONG-H

notes_Linux

3171NOTESLinux2021-11-172024-12-07

as root user: sudo su

CTRL + L clear terminal

~ is the home directory of user

Sharing SSH keys between Windows and WSL 2

  • copy the entrie .ssh from the windows path c:\Users\<username>\.ssh to linux dir ~/.ssh

cp -r /mnt/c/Users/<username>/.ssh ~/.ssh

  • chmod 600 ~/.ssh/id_rsa set Read/Write access for the owner, and no access for anyone else. That means that nobody but you can see this key.

WSL

  1. wsl --distribution Ubuntu-22.04
  2. wsl -l get distribution list
  3. wsl -s <distribution Name> set default distribution
  4. explorer.exe open file explorer

apt

  1. apt --purge remove remove package and all their global (i.e., system wide) configuration files.
  2. apt list --installed
  3. wget "<url>" download from a url

dir

mv <name> <new name> rename dir
mkdir

File access

cat <file name> read
cat > <file name> overthrow

mv <old name> <new name> rename a file
rm remove

  1. cp <options> <from path> <to path> copy dir or file
    1. multiple from path is allowed
    2. options
      1. -r recursively copy
      2. -i to prompt if there are already existing files with same names in the destination folder
      3. -p to preserver it’s timestamp, filer permission, owner ship and so on
  2. cut
  3. find <path> -name <name | regular expression > search by file name or regular expression

vi editor

vi <file name> open vi editor
:w save
:wq or zz save and exit
:q! exit without saving
i insert
d or <number>dd delete lines
b to the beginning of the word
e to the end of the word
:u or :<number>u undo
:set nu show line number
:<line number> to the given line
<number>yy yank multiple lines from the cursor position

Nano editor

ctrl + <command>