Skip to content

Instantly share code, notes, and snippets.

@ryuichi24
Last active September 6, 2022 08:09
Show Gist options
  • Save ryuichi24/d6e02b7a589d241b4197a2896ad5f04d to your computer and use it in GitHub Desktop.
Save ryuichi24/d6e02b7a589d241b4197a2896ad5f04d to your computer and use it in GitHub Desktop.
commands for linux

General

read file

less <file to path>

filter output

<some command> | grep <search input>

User management

add new user

adduser <user name>

add home directory

mkhomedir_helper <user name>

add new group

groupadd <group name>

delete group

groupdel <group name>

append user into a group

usermod -aG <group name> <user name>

remove user from group

gpasswd -d <user name> <group name>

delete user

userdel <user namn>

modify user name

usermod -l <new user name> <old user name>

set shell

usermod <user name> --shell <path to shell>

switch user

su - <user name>

switch to root (never do it)

su -

change password

passwd <user name>

check users and groups

cat /etc/passwd

apt

list all packages installed

apt list --installed

check port being used

lsof -i:<port>

kill port

kill -9 <port>

show passwd info

cat /etc/passwd

show password hash

cat /etc/shadow

show groups

cat /etc/group

modify sudo file

sudo visudo

add user into group

usermod -aG <group name> <username>

remove user from group

gpasswd -d <username> <group name>

check exit status

echo $?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment