Unix commands - kanuku/misc GitHub Wiki

Sending a task to background
nohup task.sh &
# Runs in background, output goes to nohup.out in current directory. Continues to run when you log out.
Groups
# Getting the GUID for the docker group
getent group docker
# Or
cat /etc/group

# How to add a group with a GID group ?
groupadd -g 999 docker

#Next, add a NEW user called jan to group developers:
useradd -G developers jan

# Add existing user to existing group
gpasswd -a developers jan
# Or
usermod -aG developers jan
Users
# List all users
cat /etc/passwd

# Delete user with home directory
userdel -r username
Find filename
find . -name '*oute*.class'
Synchronize folder
rsync -a source dest

Copy hidden files and folders only
cp -r /home/<user>/.[^.]* /home/<user>/backup_hidden/

chmod

Uploading files to host
scp -r test.tgz [email protected]:/tmp/

Archiving with tar
# Compress everything in the current directory
tar cvzf [filename.tgz] .
# List files in archive
tar --list -f mytarfile.tgz
# Uncompress archive
tar zxvf server-farm-credentials.tgz

Archiving with zip

Create zip file from current dir

zip -r settings.zip .

List zipped files

unzip -l settings.zip

Unzip file

unzip settings.zip

Get size of directory

du -sh directory_name

How to replace boot with an old kernel

see here


GPG Encryption

how to manage it?

Size of directory/files

du -h / --max-depth=1 2> >(grep -v 'Permission denied\|No such file or directory') | sort -hr

Deleting application logs

sudo rm -f /var/log/application.log.*
⚠️ **GitHub.com Fallback** ⚠️