🐧Linux
User Management
sudo: Execute command as a different user
su: The su utility requests appropriate user credentials via PAM and switches to that user ID (the default user is the superuser). A shell is then executed.
useradd: Creates a new user or update default new user information.
userdel: Deletes a user account and related files.
usermod: Modifies a user account.
addgroup: Adds a group to the system.
delgroup: Removes a group from the system.
passwd: Changes user password.
Package Management
Find all related packages
apt-cache search <package>
View additional information about a package
apt-cache show <package>
List all installed packages
apt list --installed
List all services using systemctl
systemctl list-units --type=service
Check the processes
ps --aux | grep <service>
Check if any services met with an error and unable to start. The following example is checking on the ssh service:
journalctl -u ssh.service --no-pager
Ge the total number of packages installed
dpkg -l | grep -c '^ii'
When using 'apt list --installed' command, the first line is actually 'Listing... Done"
apt list --installed
┌──(kali㉿kali)-[~]
└─$ apt list --installed
Listing... Done
apt list --installed | grep -c 'installed' | wc -l
Service and Process Management
systemclt start <service>
systemclt status <service>
Run a service after statup
systemclt enable<service>
Services listening on all interfaces (not on localhost and ipv4 only)
netstat -ln4 | grep LISTEN | grep -v 127 | wc -l
ss -l -4 | grep -v "127.0.0" | grep "LISTEN" | wc -l
Web Services
Python
python3 -m http.server <port>
python -m SimpleHTTPServer <port>
NPM
http-server -p 8080
PHP
php -S <localhost>:8000
Navigation
Go back to the previous directory
cd -
Find Files and Directories
Which
There will be no output if the program does not exist
which <program>
Find
find <location> <options>
┌──(kali㉿kali)-[~]
└─$ find / -type f -name *.conf -user root -size +20k -newermt 2020-03-03 -exec ls -al {} \; 2>/dev/null
-type f: Defining the type of the searched object. 'f' stands for 'file'.
-name *.conf: Indicate the name of the file we are looking for. The asterisk () stands for 'all' files with the '.conf' extension.
-user root: Filtering all files whose owner is the root user.
-size +20k: Filter all the located files that are larger than 20 KiB.
-newermt 2020-03-03: Only files newer than the specified date will be presented.
-exec ls -al {} \;: This option executes the specified command, using the curly brackets as placeholders for each result. The backslash escapes the next character from being interpreted by the shell because otherwise, the semicolon would terminate the command and not reach the redirection.
2>/dev/null: This is a STDERR redirection to the 'null device', which we will come back to in the next section. This redirection ensures that no errors are displayed in the terminal. This redirection must not be an option of the 'find' command.
Locate
Before running the 'locate' command, execute 'sudo updatedb' to update the database that 'locate' relies on
sudo updatedb
locate <search element>
Tmux
.bashrc
Explain Shell Commands
xfreerdp
xfreerdp /v:<target ip> /u:<username> /p:<password>
Last updated