Skip to content

Instantly share code, notes, and snippets.

@leimingyu
Last active January 8, 2023 17:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leimingyu/f0e3123a1f06264b4a13dd492747bbea to your computer and use it in GitHub Desktop.
Save leimingyu/f0e3123a1f06264b4a13dd492747bbea to your computer and use it in GitHub Desktop.
some linux commands

Linux Commands

Change text to uppercase

$tr a-z A-Z < input.txt

Redirect stdout/stderr to file

stdout to file

$cat input.txt  > /dev/null

stderr to file

$cat input.txt  2> /dev/null

both stdout and stderr to file

$cat input.txt > /dev/null 2>&1

check running processes by a specific user

$top -u <UserName>

show active users on the system

$w

check current user name

$whoami

Resume rsync on an interrupted transfer

The remote directory should be the absolute path, not a soft link.

$rsync -avzP local-dir remote-dir

Write a message to another user on the same linux machine

check user

$who
user1    pts/0        2007-03-10 02:21 (:0.0)

Write message, hit enter to send, ctrl+D to quit

$write user1 pts/0

tar and untar files

tar files and directories

$tar -cvzf  <xxx>.tgz  folders/  file1 file2 ....

untar compressed file

$tar -xvzf  <xxx>.tgz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment