Linux Command List

Count folder's size

du -sch /path/to/folder/*type

Set Time & Date NTP

sudo timedatectl set-ntp yes

Set default shell

sudo ln -fs /bin/bash /bin/sh

Make zstdmt as zstd

zstdmt is faster than zstd, since it uses multi-threading.

sudo ln -s /usr/bin/zstdmt /usr/bin/zstd

Add user & group

sudo adduser [username]

P.S. Don't use useradd to add user, it will not create home directory for user.

Add user to sudo group

sudo usermod -aG sudo [username]

Change user password

sudo passwd [username]

Delete user

sudo userdel -r -f [username]

Delete group

sudo groupdel -f [groupname]

Change default editor to vim

sudo update-alternatives --config editor

And then choose vim.basic:

There are 3 choices for the alternative editor (providing /usr/bin/editor).

  Selection    Path                Priority   Status
------------------------------------------------------------
* 0            /bin/nano            40        auto mode
  1            /bin/nano            40        manual mode
  2            /usr/bin/vim.basic   30        manual mode
  3            /usr/bin/vim.tiny    15        manual mode

Press <enter> to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/editor (editor) in manual mode

Use tee instead of echo to add lines into file

The redirection is done by the shell before sudo is even started.

So either make sure the redirection happens in a shell with the right permissions

sudo bash -c 'echo "hello" > f.txt'

Or use tee

echo "hello" | sudo tee f.txt  # add -a for append (>>)

Scan WiFi

sudo iwlist wlan0 scan

Search Depend packages of Application

Way 1

apt-cache depends build-essential

Way 2

apt-cache showpkg build-essential

APT Error Fix

If it shows

E: Encountered a section with no Package: header

Just clean the error link

sudo rm /var/lib/apt/lists/* -vf

And then

sudo apt-get update

Start SSH

sudo /etc/init.d/ssh start

Change SSH Port

sudo vim /etc/ssh/sshd_config

then

sudo service ssh restart

Regenerate SSH Key

ssh-keygen -R "you server hostname or ip"

Set default path of terminal

echo 'cd ~/Desktop/' >> ~/.bashrc

If in MacOS, use

echo 'cd ~/Desktop/' >> ~/.zprofile

Clear history

history -c

If in MacOS, and you're using zsh as default shell, use

history -p

Zip

zip

  • -h Show the help interface
  • -m After the file is compressed, delete the original file
  • -o Set the latest change time of all files in the archive to the time of compression
  • -q Quiet mode, does not display the execution of instructions during compression
  • -r Treats all subdirectories under the specified directory together with the file
  • -P Set the compression password

Unzip

unzip

  • -l Show the files whitch contained in the compressed file
  • -t Check if the compressed file is correct
  • -P<password> Unzip files with password

Terminal

  • Ctrl + Alt + F2 = Terminal
  • Alt + F7 = Exit Terminal

Rclone

Show process every 1 second when upload files:

rclone copy -v --stats 1s [File] [Target]

Remove rclone:

sudo rm /usr/bin/rclone
sudo rm /usr/local/share/man/man1/rclone.1

Rclone Config File

rclone -h | grep "Config file"

Screen

Kill specific screen

screen -S [pid/name] -X quit

Or

kill [pid]

Kill all screen

killall screen

results matching ""

    No results matching ""