Frequently Used Linux Commands

 

Created on: 4/3/19
Last update: 4/3/19

Manage Users

Add User

Add a new user with username:

adduser [USERNAME]

Add the user to the sudo group:

usermod -aG sudo [USERNAME]

Verify:

su - [USERNAME]
sudo su

Remove User

userdel -r mynewuser

Commands

list

List and sort by date:

ll -halt

List with file sizes in MB:

ll --block-size=M

nohup

Run a nohup task and output a log file:

nohup sh your-script.sh > /path/to/custom.out &

scp

scp filename user@host:/path/to/

dhclient

Release the current IP address and obtain a new one:

sudo dhclient -r
sudo dhclient 

du

Display the total size of specific directory:

du -hs .

find

find /home/username/ -name "*.err"

grep

grep -r "CloudStack"  .

Zip

Zip a file without including the parent directory:

zip -j folder/artifact.zip folder/artifact1.app folder/artifact2.ext2 folder/artifact3.ext3

Reference

  1. What Is Nohup and How Do You Use It?
  2. How do I request a new IP address from my DHCP server using Ubuntu Server?
  3. Zip a file without including the parent directory