System Administration
▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁
Linux system administration involves managing and maintaining Linux-based systems to ensure their optimal performance, security, and reliability. System administrators are responsible for a wide range of tasks, including installing and configuring software, managing user accounts, and monitoring system performance. They play a crucial role in ensuring that systems run smoothly and efficiently.
One of the key responsibilities of a Linux system administrator is to manage system updates and patches. This involves regularly applying security updates and software patches to protect the system from vulnerabilities and ensure that it remains up-to-date with the latest features. Administrators also need to manage system backups, ensuring that data is regularly backed up and can be restored in case of a failure.
System monitoring is another critical aspect of Linux system administration. Administrators use various tools to monitor system performance, track resource usage, and identify potential issues before they become critical. This proactive approach helps maintain system stability and prevents downtime.
Security is a top priority for Linux system administrators. They implement security measures such as firewalls, intrusion detection systems, and access controls to protect the system from unauthorized access and cyber threats. Regular security audits and vulnerability assessments are also conducted to identify and mitigate potential risks.
In addition to these tasks, Linux system administrators are responsible for managing network configurations, ensuring that systems can communicate effectively with other devices and networks. They also handle hardware management, including installing and configuring hardware components and troubleshooting hardware-related issues.
Overall, Linux system administration is a multifaceted role that requires a deep understanding of Linux systems and a proactive approach to managing and maintaining them. Administrators play a vital role in ensuring the reliability, security, and performance of Linux-based systems, making them indispensable in any organization that relies on Linux for its operations.
1 - Automation
▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁
Linux automation and orchestration tools are essential for streamlining and managing complex IT tasks and workflows. Automation tools allow administrators to automate repetitive tasks, such as software installation, configuration management, and system updates. By reducing manual intervention, these tools increase efficiency, minimize errors, and free up time for more strategic activities.
Orchestration tools take automation a step further by coordinating and managing multiple automated tasks across different systems and environments. They enable the seamless integration of various processes, ensuring that tasks are executed in the correct order and dependencies are managed effectively. This is particularly important in environments with complex workflows, such as continuous integration and continuous deployment (CI/CD) pipelines.
One of the key benefits of automation and orchestration tools is their ability to ensure consistency and standardization across systems. By using predefined scripts and templates, administrators can ensure that configurations are applied uniformly, reducing the risk of configuration drift and inconsistencies. This leads to more reliable and predictable system behavior.
These tools also enhance scalability, allowing organizations to efficiently manage large-scale deployments and infrastructure. Automation and orchestration enable rapid provisioning and scaling of resources, ensuring that systems can handle varying workloads and demands. This is crucial for maintaining performance and availability in dynamic environments.
Overall, Linux automation and orchestration tools are indispensable for modern IT operations. They improve efficiency, consistency, and scalability, enabling organizations to manage their infrastructure more effectively. Whether for routine tasks or complex workflows, these tools play a vital role in optimizing system administration and ensuring smooth and reliable operations.
1.1 - 🖥️ansible
➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the ansible command with important options and switches using examples.
▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁
# █████╗ ███╗ ██╗███████╗██╗██████╗ ██╗ ███████╗
# ██╔══██╗████╗ ██║██╔════╝██║██╔══██╗██║ ██╔════╝
# ███████║██╔██╗ ██║███████╗██║██████╔╝██║ █████╗
# ██╔══██║██║╚██╗██║╚════██║██║██╔══██╗██║ ██╔══╝
# ██║ ██║██║ ╚████║███████║██║██████╔╝███████╗███████╗
# ╚═╝ ╚═╝╚═╝ ╚═══╝╚══════╝╚═╝╚═════╝ ╚══════╝╚══════╝
#-------------------------------------------------------------------------------------------------#
# Ping der Einzelhosts aus der Datei hosts
ansible pluto -i hosts -m ping
ansible mars-i hosts -m ping
ansible staturn -i hosts -m ping
ansible venus -i hosts -m ping
ansible testserver1 -i hosts -m ping
# Ping aller Hosts in der Datei hosts
ansible '*' -i hosts -m ping
ansible-doc apt
ansible venus.srv041.lxu.io -i hosts -m command -a uptime
ansible-playbook -h hosts -i web-notls.yml
ansible pluto -i hosts -m ping
ansible pluto -i hosts -m command -a uptime
ansible pluto -i hosts -a "tail /var/log/messages"
ansible pluto -m apt "name=ccze state=installed" -b
ansible pluto -i hosts -m user -a "name=tuxtux comment=\"CheffRocker\" shell=/bin/bash state=present" -b
ansible mars -m apt -i "name=ccze state=installed" -b
ansible '*' -i hosts -m command -a 'lsof -i'
ansible '*' -i hosts -m command -a 'apt update'
ansible '*' -i hosts -m command -a 'tail /var/log/syslog'
# für alle Systeme
- name: Stop and disable firewalld
service:
name: firewalld
state: stopped
enabled: no
ignore_errors: yes
# Für Debian und SUSE basierte Systeme Handler - Ein Handler ist ähnlich wie ein Task, läuft aber nur dann, wenn er von einem Task via notify aufgerufen wird. Ein Anfwendungsfall dafür ist zum Beispiel das Neustarten eines Diensts nach einer Änderung an einer Konfigurationsdatei.
# Wir starten den Apache via Handler neu wenn sich das static.html File geändert hat. Dies ist in der Praxis natürlich nicht nötig, der Einfachheit halber wird diese Datei aber als Apache-Konfigurationsdatei betrachtet.
handlers:
- name: Restart Apache
service:
name: apache2
state: restarted
#/home/ansible/playbooks/hosts
[testgruppe]
pluto ansible_ssh_host=10.17.1.204 ansible_ssh_user=root
mars ansible_ssh_host=10.17.1.192 ansible_ssh_user=root
saturn ansible_ssh_host=10.17.1.199 ansible_ssh_user=root
[testserver]
venus ansible_ssh_host=10.16.1.128 ansible_ssh_user=root
testserver1 ansible_ssh_host=10.14.5.41 ansible_ssh_user=root
#--------/home/ansible/palybooks/upgrade.yml------------------------------------#
---
# apt update && upgrade auf allen Servern der Gruppe update mit alter source.list :
- name: Config für update Hosts
hosts: update
become: true
tasks:
# wenn nicht vorhanden installiere htop:
- name: Install htop
apt:
name: htop
state: present
update_cache: yes
# wenn nicht vorhanden installiere ccze:
- name: Install ccze
apt:
name:
- ccze
- arp-scan
state: present
update_cache: yes
# wenn nicht vorhanden installiere nmap:
- name: Install nmap
apt:
name: nmap
state: present
update_cache: yes
# Über notify wird dann ein restart von Apache initiiert:
- name: Copy proxyfile to /etc/apt/apt.conf.d/
copy:
src: files/proxyfile
dest: /etc/apt/apt.conf.d/
# Über notify wird dann ein restart von Apache initiiert:
- name: Copy sources.list to /etc/apt/
copy:
src: files/sources.list
dest: /etc/apt/
# Für Debian und SUSE basierte Systeme Handler - Ein Handler ist ähnlich wie ein Task, läuft aber nur dann, wenn er von einem Task via notify aufgerufen wird. Ein Anfwendungsfall dafür ist zum Beispiel das Neustarten eines Diensts nach einer Änderung an einer Konfigurationsdatei. Wir starten den Apache via Handler neu wenn sich das static.html File geändert hat. Dies ist in der Praxis natürlich nicht nötig, der Einfachheit halber wird diese Datei aber als Apache-Konfigurationsdatei betrachtet.
handlers:
- name: Restart Apache
service:
name: apache2
state: restarted
# 7.2 Playbook für mehrere Distributionen -Durch das gesammelte Wissen über Facts können wir das Playbook für mehrere Distributionen verfügbar machen. Es wären noch mehr Änderungen am Playbook nötig (Services, Handlers), in der Kürze des Workshops wird allerdings nur beispielhaft die Installation gezeigt.
tasks:
- name: Install Apache on RHEL
yum:
name: httpd
state: present
when: ansible_os_family == “RedHat”
- name: Install Apache on Debian
apt:
name: apache2
state: present
update_cache: yes
when: ansible_os_family == “Debian”
- name: Install Apache on SUSE
zypper:
name: apache2
state: present
when: ansible_os_family == “Suse”
- name: Copy static.html
#--------/home/ansible/palybooks/upgrade.yml------------------------------------#
# ansible historytext
ansible raspberry -m apt -a 'upgrade=yes update_cache=yes cache_valid_time=864000' --become
ansible raspberry -m command -a 'ls'
ansible raspberry -m -m apt -a 'upgrade=yes update_cache=yes cache_valid_time=864000' --become
ansible raspberry -m ping
ansible Client -m ping
ansible-config
ansible ebook -m apt -a 'upgrade=yes update_cache=yes cache_valid_time=864000' --become
ansible ebook -m ping
ansible ebook -m test.ping
ansible --list-host
ansible '*' --list-hosts
ansible * --list-hosts
ansible '*' -m apt -a 'upgrade=yes update_cache=yes cache_valid_time=864000' --become
ansible '*' -m ping
ansible '*' -m ping
ansible * -m ping
ansible nas.fritz.box -m ping
ansible nas -m ping
ansible nas -m ping
ansible proxy -m ping
ansible salt -m ping
ansible raspydisplay -m apt -a 'apt upgrade'
ansible raspydisplay -m apt 'apt upgrade'
ansible raspycdisplay -m apt -a 'upgrade=yes update_cache=yes cache_valid_time=86400' --become
ansible raspydisplay -m cmd -a 'lsof -i'
ansible raspydisplay -m command -a 'apt upgrade'
ansible raspydisplay -m command -a 'lsof -i'
ansible raspydisplay -m ping
ansible raspydisplay -m shell -a 'apt update'
ansible raspydisplay -m shell -a 'apt upgrade'
ansible raspydisplay -m shell -a 'ifconfig'
ansible raspydisplay -m shell -a 'lsof -i'
ansible raspydisplay -m shell 'ifconfig'
ansible raspy* -m ping
cat /etc/ansible/hosts
cd /etc/ansible
history | grep ansible
vi /etc/ansible/hosts
ansible raspberry -m ping
# Parallel Prozesses
-f 'FORKS', --forks 'FORKS'
# specify number of parallel processes to use (default=5)
Cheatsheets are an excellent complement to other information sources like Linux man-pages, Linux help, or How-To’s and tutorials, as they provide compact and easily accessible information. While man-pages and detailed tutorials often contain comprehensive explanations and extensive guides, cheatsheets summarize the most important options forthe command ansible in a clear format. This allows users to quickly access the needed information for ansible without having to sift through lengthy texts. Especially in stressful situations or for recurring tasks, cheatsheets for ansible are a valuable resource to work efficiently and purposefully.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
█║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌
██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗███████╗██████╗
████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
╚██╔═██╔╝██║ ██║██║ ██║ ╚███╔╝ █████╗ ██║ ██║
████████╗██║ ██║██║ ██║ ██╔██╗ ██╔══╝ ██║ ██║
╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═════╝
█║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
1.2 - 🖥️at
➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the at command with important options and switches using examples.
▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁
# █████╗ ████████╗
# ██╔══██╗╚══██╔══╝
# ███████║ ██║
# ██╔══██║ ██║
# ██║ ██║ ██║
# ╚═╝ ╚═╝ ╚═╝
#==============================#
# CMD AT
#==============================##==============================#
# To schedule a one time task
at {time}
{command 0}
{command 1}
Ctrl-d
# {time} can be either
now | midnight | noon | teatime (4pm)
HH:MM
now + N {minutes | hours | days | weeks}
MM/DD/YY
# To list pending jobs
atq
# To remove a job (use id from atq)
atrm {id}
# Schedule a one-time task using "at" command and intuitive date specifications
at now + 30 minutes
# Explanation:
# The example will run something 30 minutes from now.
# Another example: at 0815 wed -- run something at 8:15am on the next Wednesday.
# With atq you can see the list of scheduled jobs, this is good to confirm that you specified the date correctly and the job will run when you want.
# With atrm you can cancel scheduled jobs, using the job id as parameter, which you can find in the atq output.
#==============================##==============================#
# CMD AT
#==============================##==============================#
Cheatsheets are an excellent complement to other information sources like Linux man-pages, Linux help, or How-To’s and tutorials, as they provide compact and easily accessible information. While man-pages and detailed tutorials often contain comprehensive explanations and extensive guides, cheatsheets summarize the most important options forthe command at in a clear format. This allows users to quickly access the needed information for at without having to sift through lengthy texts. Especially in stressful situations or for recurring tasks, cheatsheets for at are a valuable resource to work efficiently and purposefully.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
█║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌
██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗███████╗██████╗
████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
╚██╔═██╔╝██║ ██║██║ ██║ ╚███╔╝ █████╗ ██║ ██║
████████╗██║ ██║██║ ██║ ██╔██╗ ██╔══╝ ██║ ██║
╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═════╝
█║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
1.3 - 🖥️crontab
➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the crontab command with important options and switches using examples.
▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁
# ██████╗██████╗ ██████╗ ███╗ ██╗████████╗ █████╗ ██████╗
# ██╔════╝██╔══██╗██╔═══██╗████╗ ██║╚══██╔══╝██╔══██╗██╔══██╗
# ██║ ██████╔╝██║ ██║██╔██╗ ██║ ██║ ███████║██████╔╝
# ██║ ██╔══██╗██║ ██║██║╚██╗██║ ██║ ██╔══██║██╔══██╗
# ╚██████╗██║ ██║╚██████╔╝██║ ╚████║ ██║ ██║ ██║██████╔╝
# ╚═════╝╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝ ╚═╝╚═════╝
# set a shell
SHELL=/bin/bash
# crontab format
* * * * * command_to_execute
- - - - -
| | | | |
| | | | +- day of week (0 - 7) (where sunday is 0 and 7)
| | | +--- month (1 - 12)
| | +----- day (1 - 31)
| +------- hour (0 - 23)
+--------- minute (0 - 59)
# example entries
# every 15 min
*/15 * * * * /home/user/command.sh
# every midnight
* 0 * * * /home/user/command.sh
# every Saturday at 8:05 AM
5 8 * * 6 /home/user/command.sh
# Allowed special character (*, -, /, ?, #)
#-------------------------------------------
Asterik(*) – Match all values in the field or any possible value.
Hyphen(-) – To define range.
Slash (/) – 1st field /10 meaning every ten minute or increment of range.
Comma (,) – To separate items.
# System Wide Cron Schedule
#===========================
# System administrator can use predefine cron directory as shown below.
/etc/cron.d
/etc/cron.daily
/etc/cron.hourly
/etc/cron.monthly
/etc/cron.weekly
# Special Strings for Common Schedule
#--------------------------------------
Strings Meanings
@reboot Command will run when the system reboot.
@daily Once per day or may use @midnight.
@weekly Once per week.
@yearly Once per year. we can use @annually keyword also.
# Multiple Commands with Double amper-sand(&&)
#---------------------------------------------
In below example command1 and command2 run daily.
# crontab -e
@daily <command1> && <command2>
# Disable Email Notification.
#------------------------------
# By default cron send mail to user account executing cronjob. If you want to disable it add your cron job similar to below example. Using >/dev/null 2>&1 option at the end of the file will redirect all the output of the cron results under /dev/null.
crontab -e
* * * * * >/dev/null 2>&1
crontab -l | tee crontab-backup.txt | sed 's/old/new/' | crontab –
# Send mail to root when crontab command fails to run
#Got a script that gets executed by crontab as the Apache user. Had a problem with my deployment script where it didn't give the Apache user permissions to execute the script after deploying it. Crontab would call the script and it would silently fail because the Apache user didn't have permissions to run it.
# I wanted to get notified when this happened outside of the normal notifications the script itself does, in case script fails to run altogether.
# Adding || mail -s "Error $? running $_" root to my script achieved this. What it does is emails root with the exit code and the command name in the subject line, e.g.: Subject: Error 126 running drush.cron. Bash exit code 126 means command not executable, e.g. permission denied.
# Example of how it looks in /etc/crontab:
*/15 * * * * www-data drush.cron || mail -s "Error $? running $_" root
# Another example with script's normal output (stdout) being discared (e.g. mail sent only if script exits with an error or script execution fails in the first place):
*/15 * * * * www-data drush.cron 1>/dev/null || mail -s "Error $? running $_" root
# Monitoring of Crons
"&&" is used to chain commands together, such that the next command is run if and only if the preceding command exited without errors (or, more accurately, exits with a return code of 0). - Source We ran our Symfony cron command with ping to OpsGenie like below:
bin/console our-cron:command && curl -X GET 'https://api.opsgenie.com/v2/heartbeats/our-cron/ping' --header 'Authorization: GenieKey '"$OPSGENIE_API_KEY"''
# We did a bit different variation to the above command and created a bash script where the command and name of the heartbeat were sent as parameters.
# Redirect stdout to /dev/null (only print output sent to stderr):
./test 1>/dev/null
# Redirect stderr to /dev/null (only print output sent to stdout):
./test 2>/dev/null
# Redirect all output to /dev/null (print nothing):
./test &>/dev/null
#==============================##==============================#
# CMD crontab #
#==============================##==============================#
Cheatsheets are an excellent complement to other information sources like Linux man-pages, Linux help, or How-To’s and tutorials, as they provide compact and easily accessible information. While man-pages and detailed tutorials often contain comprehensive explanations and extensive guides, cheatsheets summarize the most important options forthe command crontab in a clear format. This allows users to quickly access the needed information for crontab without having to sift through lengthy texts. Especially in stressful situations or for recurring tasks, cheatsheets for crontab are a valuable resource to work efficiently and purposefully.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
█║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌
██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗███████╗██████╗
████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
╚██╔═██╔╝██║ ██║██║ ██║ ╚███╔╝ █████╗ ██║ ██║
████████╗██║ ██║██║ ██║ ██╔██╗ ██╔══╝ ██║ ██║
╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═════╝
█║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
1.4 - 🖥️salt
➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the salt command with important options and switches using examples.
▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁
# ███████╗ █████╗ ██╗ ████████╗
# ██╔════╝██╔══██╗██║ ╚══██╔══╝
# ███████╗███████║██║ ██║
# ╚════██║██╔══██║██║ ██║
# ███████║██║ ██║███████╗██║
# ╚══════╝╚═╝ ╚═╝╚══════╝╚═╝
# Saltstack ist eine Softwareverwaltung für Linux und Windows, mit der eine große Anzahl von Systemen verwaltet werden kann
#------------#
# Todo Bei einem neuen Minion:
#-------------------------------#
1. apt install salt-minion
2. vi /etc/hosts muss die DMZ Adresse drin sein wie z.B.
# 10.254.253.47 salt
3. vi /etc/salt/minion_id >
# FQDN wie z.B. proxy.lxu.io
4. Am Salt Master schauen ob es neue Minions gibt
salt-key -L
5. DMZ
# Destination dmz.lxu.io (dmz Adresse) <-> DMZ = source
# Ports TCP 4505 und TCP 4506 müssen eingehen an der Inside Firewall offen sein
# DMZ muss in /etc/hosts eintrag rein:
# 10.254.254.10 salt
6. in der /etc/salt/minion_id
#muss der hostname in FQDN rein
### Installation
# -------------
# cname salt auf master einrichten -> salt.lxu.io
# Master
apt-get install salt-master
# Miniom
apt-get install salt-minion
### Administration (remote execution)
# ----------------------------------
# auf der Kommandozeile des Masters als root:
## Minions hinzufügen:
# -> zeigt accepted und unaccepted Clients an
salt-key -L
# -> fügt accepted Clients hinzu
salt-key -A
## Verwaltung:
salt-run manage.status
salt '*' test.ping
salt '*' cmr.run 'ls -l /etc/hosts'
salt '*' cmd.run 'lsb_release -d'
salt '*' network.interfaces
salt '*' status.loadavg
salt '*' disk.usage
salt '*' status.uptime
# Alle verfügbaren Module anschauen:
salt 'SERVER*' sys.doc | grep -E "^\w"
# Nur Befehle für pkg-Modul anschauen
salt 'SERVER*' sys.doc pkg
# Paket Version anschauen
salt 'SERVER.lxu.io' pkg.version vim
# Paket installieren
sealt 'SERVER.lxu.io' pkg.install vim
# Paket löschen
sealt 'LINUX-SERVER.lxu.io' pkg.purge vim
# Pakete updaten
salt 'SERVER*' pkg.list_upgrades
salt '*' pkg.upgrade
salt 'LINUX-SERVER.lxu.io' pkg.upgrade dryrun=True
# Achtung, nicht alle Maschinen gleichzeitig booten
salt 'LINUX-SERVER.lxu.io' system.reboot
# Password generieren
salt 'minion_id' shadow.gen_password 'Plaintext_Password'
# Passwort ändern
salt 'minion_id' shadow.set_password root 'Password_Hash'
### States (system states)
# ---------------------
# zuerst in /etc/salt/master fileserver konfigurieren
file_roots:
base:
- /srv/salt
# dann /etc/init.d/salt-master restart
/srv/salt/top.sls Kommandozentrale
/srv/salt/vim Pakte
# einen State ausführen:
salt -v 'LINUX-SERVER.lxu.io' state.sls vim
# state.apply = state.highstate oder state.sls
salt 'LINUX-SERVER' state.apply vim
### Pillars (system variables)
# --------------------------
### Garin (Oberflächenbild)
# ------------------------
# Grains auflisten
salt 'LINUX-SERVER.lxu.io' grains.items
# Grain addressieren
salt -G 'virtual:VMware' test.ping
### Addressieren von Minions
# -------------------------
## 1. Liste
# in top.sls
'LINUX-SERVER.lxu.io,proxy.lxu.io'
- match: list
# addressieren
salt -L
## 2. Nodegroups
# konfigurieren der Gruppe in /etc/salt/master
# in top.sls
proxy:
- match: nodegroup
# addressieren
salt -N ...
salt -N 'dnsdmz' state.sls bind
salt -N 'mailrelay' state.highstate postfixmailrelay
# oder
salt -N 'mailrelay' state.sls postfixmailrelay
# dazu muss postfixmailrelay nicht in top eingetragen sein
###########################################
# Verzeichnis auf lxu.io/srv/salt
#####################################
# alle hosts die mit dns beginnen werden angepingt
salt 'dns*' test.ping
# alle hosts die mit dns beginnen wird folgendes ausgeführt:
salt 'dns*' state.sls agentsdns
############ /srv/salt/agentsdns.sls ##########
# agent auf den sdns-Server installieren
# check-mk-agent:
# pkg.purged: []
# cmd.run:
# - name: rm -f /root/check-mk-agent*deb
# checkmkagent:
# cmd.run:
# - name: dpkg -i /root/check-mk-agent_1.2.8p18_all.deb
# - require:
# - file: /root/check-mk-agent_1.2.8p18_all.deb
# /root/check-mk-agent_1.2.8p18_all.deb:
# file.managed:
# - source: salt://deploy/checkmk/check-mk-agent_1.2.8p18_all.deb
# register:
# cmd.run:
# - name: cmk-update-agent register -vvv --secret SECRETPASS
# Packet Upgrades verfügber?
salt 'unix.lxu.io' pkg.list_upgrades
# Packete Upgraden
salt 'unix.lxu.io' pkg.upgrade
# dhcpdconfsdns.sls ausfürhen (alle configs auf allen dhcp server austauschen)
salt 'dhcp.lxu.*' state.sls dhcpdconfsdns
# config verzeichnis [email protected]:/srv/salt/deploy/dhcpdsdns
history | awk '{print $4,$5,$6,$7,$8,$9,$10}' | grep -i salt
cd /srv/salt/deploy/
salt-key -L
salt-key -L | grep voip
salt-key -L | grep prx
salt-key -A
salt-key -L | wc -l
salt 'dns.lxu.io' state.highstate
salt-cmd proxy.lxu.io test.ping
salt apache.lxu.io test.ping
# drüberkopieren
salt-cp dhcp.lxu.io ./sysctl.conf /etc/
salt-cp proxy.lxu.io ./sysctl.conf /etc/
salt nginx.lxu.io cmd.run 'sysctl -p'
salt nbinx.lxu.io cmd.run 'sysctl -p'
salt proxy.lxu.io cmd.run 'sysctl -p'
salt-key -d bind9.lxu.io
salt 'saltstack.lxu.io' state.highstate
# Anpingen eines Servers
salt unix-srv50.lxu.io test.ping
salt unix-srv360.lxu.io test.ping
salt '*' cmd.run 'lsb_release -d'
salt 'proxy*' pkg.update
salt 'server1.lxu.io' pkg.upgrade
salt '*.lxu.io' pkg.install linux-image-amd64
salt 'ssh.lxu.io' state.sls vim
salt '*.lxu.io' pkg.autoremove purge=True
salt 'dhcp.lxu.io' system.reboot
salt 'squidproxy*' cmd.run 'tail /var/log/squid/access.log'
salt -N 'mailrelay' state.sls postfixmailrelay
# Eine Nodegroup wird unter /etc/salt/master erstellt - z.b. nodegroup unix-srv:
unix-srv: '[email protected],unix-srv379.lxu.io,unix-srv380.lxu.io,unix-srv381.lxu.io,unix-srv383.lxu.io,unix-srv384.lxu.io,unix-srv389.lxu.io,unix-srv390.lxu.io,unix-srv391.lxu.io,unix-srv392.lxu.io,unix-srv393.lxu.io,unix-srv394.lxu.io,unix-srv770.lxu.io,unix-srv774.lxu.io,unix-srv777.lxu.io,unix-srv260.lxu.io,unix-srv260.lxu.io'
salt -N 'unix-srv' cmd.run 'lsb_release -d'
salt -N 'unix-srv' cmd.run 'tail -n 10 /var/log/daemon.log'
salt -N 'unix-srv' cmd.run 'tail -n 10 /var/log/daemon.log'
#-----------------------------------------------------------------------///
# Port 4506 Saltstack
#-----------------------------------------------------------------------///
# Beispiel: Benutzer anlegen
salt * user.add thorsten
# Benutzer auf allen Systemen anlegen
salt '*' ssh.set_auth_key admin AAAAB3NzaC2y…p8cxw==enc='rsa' comment='[email protected]'
# Einen öffentlichen SSH-Schlüssel hinterlegen
salt '*' user.chshell admin /bin/bash
salt * cmd.run "lsb_release -d"
salt * pkg.upgrade
# Beispiel: Benutzer anlegen
salt * user.add thorsten
# Benutzer auf allen Systemen anlegen
salt '*' ssh.set_auth_key admin AAAAB3NzaC2y…p8cxw==enc='rsa' comment='[email protected]'
# Einen öffentlichen SSH-Schlüssel hinterlegen
salt '*' user.chshell admin /bin/bash
# Minions adressieren (Grain = Oberflächenbild)
salt -G "os_family:RedHat" test.ping
# unter der Oberfläche
salt minion1.lxu.io grains.items
# States definieren in /etc/salt/master
file_roots:
base:
- /srv/salt
# Die Kommandobrücke: top.sls
/srv/salt/top.sls
# Benutzer verwalten
/srv/salt/create_user.sls
### Push & Pull
# -------------
# Pull - Minions holen sich alle States ab: root@minion2:~
salt-call state.highstate
# Push - Master schickt alle Sates (top.sls): root@master:~
salt minion1.lxu.io state.highstate
# Master schickt einen State: root@master:~#
salt minion1.lxu.io state.sls create_user
# dynamische Dateien mit Jinja
#-----------------------------------------------------------------------///
# Upgade Buster
/etc/apparmor.d/local/usr.sbin.named
# alle die mit linux- anfangen - rausfinden wie die wirktlich heißen
salt 'linux-*' cmd.run 'hostname'
# System testpingen
salt 'linux-sftp.lxu.io' test.ping
# System upgraden
salt 'linux-sftp.lxu.io' pkg.upgrade dist_upgrade=yes
# Alten system aufräumen
salt 'linux-sftp.lxu.io' pkg.autoremove
# System upgraden
salt 'linux-sftp.lxu.io' pkg.upgrade dist_upgrade=yes
# reboot
salt 'linux-sftp.lxu.io' system.reboot
# testen ob 10 läuft
salt 'linux-sftp.lxu.io' '*' cmd.run 'lsb_release -d'
# Shell Variable setzen
[email protected]:/srv/salt# MyServer=lxu.io
[email protected]:/srv/salt# echo $MyServer
#-----------------------------------------------------------------#
salt '$MyServer' pkg.upgrade dist_upgrade=yes
salt '$MyServer' state.sls upgrade
salt '$MyServer' pkg.upgrade dist_upgrade=yes
# -> Minion did not return. [Not connected]
# dauert weile -> 5min bis minion wieder da ist
salt '$MyServer' pkg.autoremove
salt '$MyServer' system.reboot
salt '$MyServer' test.ping
[email protected]:/srv/salt# MyServer=linux.lxu.io
[email protected]:/srv/salt# echo $MyServer
#-----------------------------------------------------------------#
salt -N '2upgrade' pkg.upgrade dist_upgrade=yes
salt -N '2upgrade' state.sls upgrade
salt -N '2upgrade' pkg.upgrade dist_upgrade=yes
# -> Minion did not return. [Not connected]
# dauert weile -> 5min bis minion wieder da ist
salt -N '2upgrade' pkg.autoremove
salt -N '2upgrade' system.reboot
salt -N '2upgrade' test.ping
# Tests
salt -N '2upgrade' cmd.run 'service isc-dhcp-server status'
salt -N '2upgrade' cmd.run 'service bind9 status'
salt -N '2upgrade' cmd.run 'tail -n 50 /var/log/daemon.log'
salt -N '2upgrade' cmd.run 'dig @localhost linux.lxu.io'
salt -N '2upgrade' cmd.run 'dig @localhost google.com'
## recive Files from salt-minion
# gehen ins verzeichnis: -> /var/cache/salt/master/minions/linux.lxu.io/files/root
# -> salt linux.lxu.io cp.push /root/testdatei
salt linux.lxu.io cp.push /root/testdatei
# copiert von remote nach /var/cache/salt/master/minions/mx.lxu.io/files/*
salt -N mxn cp.push_dir /etc/postfix/
salt linux.lxu.io cp.push /etc/dhcp/
salt mx.lxu.io cp.push_dir /etc/postfix/
salt mx.lxu.io cp.push_dir /etc/rspamd/
salt mx.lxu.io cp.push_dir /var/lib/clamav/
# von . local das script nach /usr/local/bin zu den minions kopieren
salt-cp dhcp.lxu.io 'dhcplease-monitor.sh' '/usr/local/bin'
# auf minions remote dateirecht des scripts ändern auf execuable
salt dhcp.lxu.io cmd.run 'chmod +x /usr/local/bin/dhcplease-monitor.sh'
# Testping auf dhcp.lxu.io
salt 'dhcp.lxu.io*' test.ping
# Copy des scripts nach /usr/local/bin
salt-cp 'dhcp.lxu.io*' 'dhcplease-monitor.sh' '/usr/local/bin'
# chmod eines scripts über
salt 'dhcp.lxu.io*' cmd.run 'chmod u+x /usr/local/bin/dhcplease-monitor.sh'
#==============================##==============================#
# CMD SALT #
#==============================##==============================#
Cheatsheets are an excellent complement to other information sources like Linux man-pages, Linux help, or How-To’s and tutorials, as they provide compact and easily accessible information. While man-pages and detailed tutorials often contain comprehensive explanations and extensive guides, cheatsheets summarize the most important options forthe command salt in a clear format. This allows users to quickly access the needed information for salt without having to sift through lengthy texts. Especially in stressful situations or for recurring tasks, cheatsheets for salt are a valuable resource to work efficiently and purposefully.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
█║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌
██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗███████╗██████╗
████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
╚██╔═██╔╝██║ ██║██║ ██║ ╚███╔╝ █████╗ ██║ ██║
████████╗██║ ██║██║ ██║ ██╔██╗ ██╔══╝ ██║ ██║
╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═════╝
█║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
1.5 - 🖥️saltstack
➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the saltstack command with important options and switches using examples.
▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁
# ███████╗ █████╗ ██╗ ████████╗███████╗████████╗ █████╗ ██████╗██╗ ██╗
# ██╔════╝██╔══██╗██║ ╚══██╔══╝██╔════╝╚══██╔══╝██╔══██╗██╔════╝██║ ██╔╝
# ███████╗███████║██║ ██║ ███████╗ ██║ ███████║██║ █████╔╝
# ╚════██║██╔══██║██║ ██║ ╚════██║ ██║ ██╔══██║██║ ██╔═██╗
# ███████║██║ ██║███████╗██║ ███████║ ██║ ██║ ██║╚██████╗██║ ██╗
# ╚══════╝╚═╝ ╚═╝╚══════╝╚═╝ ╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝
#########################
# saltstack cheat sheet
############################
SaltStack master operations
salt-key -L -> Showing all minions
salt-key -a <minion_id> -> Accepting an unaccepted minion
salt-key -A -> Accepting all unaccepted minions
salt-key -d <minion_id> -> Removing a minion
salt '*' state.sls nginx -> Running formula
salt '*' cmd.run 'ls -l /etc'
salt '*' pkg.install vim
salt '*' network.interfaces
salt '*' test.echo 'foo: bar'
salt-call -> masterless minion.
salt '*' state.apply vim -> Run /srv/salt/vim.sls
sudo salt-key -F master
#Install master/node
#master node
#----------------------#
sudo apt-get update -y
sudo apt-get dist-upgrade -y
sudo apt-get install salt-master salt-ssh salt-cloud salt-doc -y
sudo vi /etc/salt/master
# The address of the interface to bind to:
interface: 192.168.39.11
sudo salt-key -a ubuntu
sudo salt-key -L
sudo service salt-master restart
sudo service salt-master status
sudo mkdir -p /srv/salt/
sudo mkdir -p /srv/salt/nginx
sudo vi /srv/salt/nginx/init.sls
nginx:
pkg:
- installed
sudo salt ubuntu state.sls nginx
sudo salt ubuntu test.ping
#slave node
#----------------------#
apt-get update -y
apt-get dist-upgrade -y
apt-get install salt-minion -y
sudo vi /etc/salt/minion
# Set the location of the salt master server. If the master server cannot be
# resolved, then the minion will fail to start.
master: 192.168.39.11
sudo service salt-minion restart
################ # SaltStack Cheat Sheet ###########################
SaltStack Cheat Sheet .. My collection of often used commands on my Salt master.
This list is partly inspired by the fine lists on:
* http://www.xenuser.org/saltstack-cheat-sheet/
* https://github.com/saltstack/salt/wiki/Cheat-Sheet
- [SaltStack Cheat Sheet]
- [First things first : Documentation]
- [Documentation on the system]
- [Documentation on the web]
- [Minions]
- [Minion status]
- [Target minion with state files]
- [Grains]
- [Jobs in Salt]
- [Sysadmin specific]
- [System and status]
- [Packages]
- [Check status of a service and manipulate services]
- [Network]
- [Salt Cloud]
# Documentation
This is important because the help system is very good.
## Documentation on the system
#--------------------------------------#
salt '*' sys.doc # output sys.doc (= all documentation)
salt '*' sys.doc pkg # only sys.doc for pkg module
salt '*' sys.doc network # only sys.doc for network module
salt '*' sys.doc system # only sys.doc for system module
salt '*' sys.doc status # only sys.doc for status module
## Documentation on the web
#--------------------------------------#
- SaltStack documentation: http://docs.saltstack.com/en/latest/
- Salt-Cloud: http://docs.saltstack.com/en/latest/topics/cloud/
- Jobs: http://docs.saltstack.com/en/latest/topics/jobs/
# Minions
## Minion status
#--------------------------------------#
You can also use several commands to check if minions are alive and kicking but I prefer manage.status/up/down.
salt-run manage.status # What is the status of all my minions? (both up and down)
salt-run manage.up # Any minions that are up?
salt-run manage.down # Any minions that are down?
salt-run manage.alived # Show all alive minions
salt '*' test.version # Display salt version
salt '*' test.ping # Use test module to check if minion is up and responding.
# (Not an ICMP ping!)
## Target minion with state files
#--------------------------------------#
Apply a specific state file to a (group of..) minion(s). Do not use the .sls extension. (just like in the state files!)
salt '*' state.sls mystatefile # mystatefile.sls will be applied to *
salt 'minion1' state.sls prod.somefile # prod/somefile.sls will be applied to minion1
## Grains
#--------------------------------------#
List all grains on all minions
salt '*' grains.ls
Look at a single grains item to list the values.
salt '*' grains.item os # Show the value of the OS grain for every minion
salt '*' grains.item roles # Show the value of the roles grain for every minion
Manipulate grains.
salt 'minion1' grains.setval mygrain True # Set mygrain to True (create if it doesn't exist yet)
salt 'minion1' grains.delval mygrain # Delete the value of the grain
# Jobs in Salt
Some jobs operations that are often used. (http://docs.saltstack.com/en/latest/topics/jobs/)
salt-run jobs.active # get list of active jobs
salt-run jobs.list_jobs # get list of historic jobs
salt-run jobs.lookup_jid <job id number> # get details of this specific job
# Sysadmin specific
Some stuff that is specifically of interest for sysadmins.
## System and status
#--------------------------------------#
salt 'minion-x-*' system.reboot # Let's reboot all the minions that match minion-x-*
salt '*' status.uptime # Get the uptime of all our minions
## Packages
#--------------------------------------#
salt '*' pkg.list_upgrades # get a list of packages that need to be upgrade
salt '*' pkg.upgrade # Upgrades all packages via apt-get dist-upgrade (or similar)
salt '*' pkg.version bash # get current version of the bash package
salt '*' pkg.install bash # install or upgrade bash package
salt '*' pkg.install bash refresh=True # install or upgrade bash package but
# refresh the package database before installing.
## Check status of a service and manipulate services
#--------------------------------------#
salt '*' service.status <service name>
salt '*' service.available <service name>
salt '*' service.start <service name>
salt '*' service.restart <service name>
salt '*' service.stop <service name>
## Network
#--------------------------------------#
Do some network stuff on your minions.
salt 'minion1' network.ip_addrs # Get IP of your minion
salt 'minion1' network.ping <hostname> # Ping a host from your minion
salt 'minion1' network.traceroute <hostname> # Traceroute a host from your minion
salt 'minion1' network.get_hostname # Get hostname
salt 'minion1' network.mod_hostname # Modify hostname
# Salt Cloud
Salt Cloud is used to provision virtual machines in the cloud. (surprise!) (http://docs.saltstack.com/en/latest/topics/cloud/)
salt-cloud -p profile_do my-vm-name -l debug # Provision using profile_do as profile
# and my-vm-name as the virtual machine name while
# using the debug option.
salt-cloud -d my-vm-name # destroy the my-vm-name virtual machine.
salt-cloud -u # Update salt-bootstrap to latest develop version on GitHub.
############# # SaltStackCheatSheet # ####################
This code is a part from "SaltStack For DevOps" Book : https://leanpub.com/saltstackfordevops/
Official website: http://saltstackfordevops.com
[](https://leanpub.com/saltstackfordevops/)
## Installing SaltStack - Ubuntu 14.*
#--------------------------------------#
wget -O - https://repo.saltstack.com/apt/ubuntu/ubuntu14/latest/SALTSTACK-GPG-KEY.pub | sudo apt-key add -
echo 'deb http://repo.saltstack.com/apt/ubuntu/ubuntu14/latest trusty main' | sudo tee -a /etc/apt/sources.list
sudo apt-get update
# Master installation
apt-get install salt-master
# Minion installation
apt-get install salt-minion
# Salt ssh installation
apt-get install salt-ssh
# Salt syndic installation
apt-get install salt-syndic
# Salt API installation
apt-get install salt-api
## Bootstrapping Salt Minion
#--------------------------------------#
curl -L https://bootstrap.saltstack.com -o install_salt.sh && sudo sh install_salt.sh
## Salt Key Management
#--------------------------------------#
# Listing Salt requests
salt-key -L
# Accepting all requests
salt-key -A
# Accepting a single request (from myNode)
salt-key -a myNode
# Removing the key of a Salt 'myNode' Minion
salt-key -d minion_id
## Debugging
#--------------------------------------#
# Debugging the master
salt-master -l debug
# Debugging the minion
salt-minion -l debug
# Restarting the minion without cache
stop master/minion
rm -rf /var/cache/salt
start master/minion
## SaltStack Documentation
#--------------------------------------#
# Viewing all the documentation
salt '*' sys.doc
# Viewing a module documentation
salt '*' sys.doc module_name
#Examples:
salt '*' sys.doc status
salt '*' sys.doc pkg
salt '*' sys.doc network
salt '*' sys.doc system
salt '*' sys.doc cloud
# Viewing a function documentation
salt '*' sys.doc module_name function_name
# Examples:
salt '*' sys.doc auth django
salt '*' sys.doc sdb sqlite3
## SaltStack Modules And Functions
#--------------------------------------#
salt '*' sys.list_modules
salt '*' sys.list_functions
## Compound Matchers
#--------------------------------------#
| Letter | Match Type | Example | Alt Delimiter?] |
| --- | --- | --- | --- |
| G | Grains glob | G@os:Ubuntu | Yes |
| E | PCRE Minion ID | E@web\d+\.(dev\|qa\|prod)\.loc | No |
| P | Grains PCRE | P@os:(RedHat\|Fedora\|CentOS) | Yes |
| L | List of minions | [email protected],minion3.domain.com or bl*.domain.com | No |
| I | Pillar glob | I@pdata:foobar | Yes |
| J | Pillar PCRE | J@pdata:^(foo\|bar)$ | Yes |
| S | Subnet/IP address | [email protected]/24 or [email protected] | No |
| R | Range cluster | R@%foo.bar | No |
Other examples:
# Examples taken from: https://docs.saltstack.com/en/latest/topics/targeting/compound.html
# Joining
salt -C 'webserv* and G@os:Debian or E@web-dc1-srv.*' test.ping
salt -C '( ms-1 or G@id:ms-3 ) and G@id:ms-3' test.ping
# Excluding
salt -C 'not web-dc1-srv' test.ping
## Upgrades & Versions
#--------------------------------------#
# Listing upgrades
salt '*' pkg.list_upgrades
# Upgrading
salt '*' pkg.upgrade
# List the packages currently installed as a dict
salt '*' pkg.list_pkgs versions_as_list=True
# Refresh the pkgutil repo database
salt '*' pkgutil.refresh_db
# Check the version of a package
salt '*' pkgutil.version mongodb
## Packages Manipulation
#--------------------------------------#
# Installation
salt '*' pkg.install apache2
# Latest version installation
salt '*' pkgutil.latest_version mysql-common
# Removing package(s)
salt '*' pkg.remove vim
# Purging package(s)
salt '*' pkg.purge apache2 mysql-server
## Reboot & Uptime
#--------------------------------------#
# Reboot
salt '*' system.reboot
#Uptime
salt '*' status.uptime
## Using Grains
#--------------------------------------#
# Syncing grains
salt '*' saltutil.sync_grains
# Available grains can be listed by using the ‘grains.ls’ module:
salt '*' grains.ls
# Grains data can be listed by using the ‘grains.items’ module:
salt '*' grains.items
# Grains have values that could be called via ‘grains.get <grain_name>’ (path is the name of a grain)
salt '*' grains.get path
## Syncing Data
#--------------------------------------#
# Syncing grains
salt '*' saltutil.sync_grains
# Syncing everything from grains to modules, outputters, renderers, returners, states and utils.
salt '*' saltutil.sync_all
## Running System Commands
#--------------------------------------#
salt "*" cmd.run "ls -lrth /data"
salt "*" cmd.run "df -kh /data"
salt "*" cmd.run "du -sh /data"
## Working With Services
#--------------------------------------#
# Apache example
# Checking if service is available
salt '*' service.available apache2
# Manipulating Apache2 service
salt '*' service.status apache2
salt '*' service.start apache2
salt '*' service.restart apache2
salt '*' service.stop apache2
## Network Management
#--------------------------------------#
# Get IP of your minion
salt '*' network.ip_addrs
# Ping a host from your minion
salt '*' network.ping localhost
# Traceroute a host from your minion
salt '*' network.traceroute localhost
# Get hostname
salt '*' network.get_hostname
# Modify hostname to 'myNode'
salt '*' network.mod_hostname myNode
# Information on all of the running TCP connections
salt '*' network.active_tcp
# Return the arp table from the minion
salt '*' network.arp
# Test connectivity
salt '*' network.connect google-public-dns-a.google.com port=53 proto=udp timeout=3
# Get default route
salt '*' network.default_route
# Execute dig
salt '*' network.dig eon01.com
# Get the MAC addres of eth0 interface
salt '*' network.hw_addr eth0
# Get the inet addres of eth1 interface
salt '*' network.interface eth1
# Get the IP addres of tun interface
salt '*' network.interface_ip tun
## Working With HTTP Requests
#--------------------------------------#
# Get the html source code of a page
salt-run http.query http://eon01.com text=true
# Get the header of a page
salt-run http.query http://eon01.com headers=true
# Get the response code from a web server
salt-run http.query http://eon01.com status=true
# Sending a post request
salt '*' http.query http://domain.com/ method=POST params='key1=val1&key2=val2'
## Job Management ##
#--------------------------------------#
# List active jobs
salt-run jobs.active
# List all jobs with the id and other information
salt-run jobs.list_jobs
# List multiple information about the job with the id:20151101225221651308 like the result output
salt-run jobs.lookup_jid 20151101225221651308
# Kill the job with the id:20151101225221651308
salt 'server' saltutil.kill_job 20151101225221651308
## Scheduling Feature ##
#--------------------------------------#
# Schedule a job called "scheduled_job"
salt '*' schedule.add scheduled_job function='cmd.run' job_args="['']" seconds=10
# Enable the job
salt '*' schedule.enable_job scheduled_job
# Disable the job
salt '*' schedule.disable_job scheduled_job
## Working With SLS
salt '*' state.show_sls
## Testing States ##
#--------------------------------------#
salt '*' state.highstate test=True
salt '*' state.sls test=True
salt '*' state.single test=True
## Load testing
#--------------------------------------#
# Starting 20 minions
wget https://raw.githubusercontent.com/saltstack/salt/develop/tests/minionswarm.py; python minionswarm.py -m 20 --master salt-master;
## State Declaration Structure ##
# Source: https://docs.saltstack.com/en/latest/ref/states/highstate.html#state-declaration
# Standard declaration
<ID Declaration>:
<State Module>:
- <Function>
- <Function Arg>
- <Function Arg>
- <Function Arg>
- <Name>: <name>
- <Requisite Declaration>:
- <Requisite Reference>
- <Requisite Reference>
# Inline function and names
<ID Declaration>:
<State Module>.<Function>:
- <Function Arg>
- <Function Arg>
- <Function Arg>
- <Names>:
- <name>
- <name>
- <name>
- <Requisite Declaration>:
- <Requisite Reference>
- <Requisite Reference>
# Multiple states for single id
<ID Declaration>:
<State Module>:
- <Function>
- <Function Arg>
- <Name>: <name>
- <Requisite Declaration>:
- <Requisite Reference>
<State Module>:
- <Function>
- <Function Arg>
- <Names>:
- <name>
- <name>
- <Requisite Declaration>:
- <Requisite Reference>
## SaltStack Github Repositories ##
- *Django* with SaltStack https://github.com/wunki/django-salted
- Salt GUI pad https://github.com/tinyclues/saltpad
- *Openstack* automation with SaltStack https://github.com/CSSCorp/openstack-automation
- A curated collection of working salt *states* and configurations for use in your saltstack setup. https://github.com/saltops/saltmine
- These are all of the configuration files needed to built a *Wordpress* development environment with *Vagrant*, *Virtual Box* and SaltStack https://github.com/paulehr/saltstack-wordpress
- *Java* bindings for the SaltStack API https://github.com/SUSE/saltstack-netapi-client-java
- *Vim* snippets for SaltStack *states* files https://github.com/StephenPCG/vim-snippets-salt
- Metrics for SaltStack https://github.com/pengyao/salt-metrics
- Salt GUI https://github.com/saltstack/halite
######### SaltStack examples ################ https://www.unixmen.com/saltstack-examples/
# SaltStack platform or Salt is a Python-based open source configuration management software and remote execution engine. Supporting the “Infrastructure as Code” approach to deployment and cloud management, it competes primarily with Puppet, Chef, and Ansible.
# We will use some of default functions., Please considerate the Link bellow about the installation of Saltstack master and nodes. and please remember all these solutions are tested in our Unixmen virtual machines, jut to be sure that every thing is working fine.
# Lets start :
Install and configure SaltStack server in Ubuntu x64
# Show disk usage for all minions:
sudo salt ‘*’ disk.usage
# Show exist documentations for all minions:
sudo salt ‘*’ sys.doc
# Check network status to all minions:
sudo salt ‘*’ test.ping
# Look at the /etc file system for all minions:
sudo salt ‘*’ cmd.run ‘ls -l /etc’
# Get system information from all minion installed servers:
/srv/pillar$ sudo salt “*” grains.items
# Check just FreeBSD minion:
/srv/pillar$ sudo salt -G ‘os:FreebSD’ test.ping
node4salt.opeensource.az:
True
# pkg function automatically get minion internal functionality. This means, the pkg.install command automatically will use yum for RedHat/Centos, for apt Ubuntu/Debian and pkg for FreeBSD.
# Install vim package to node4salt.opensource.az FreeBSD server as follows:
sudo salt ‘node4salt.opensource.az’ pkg.install vim
# Get information from all minions about network card names, IP address, subnets with masks and MAC address:
sudo salt ‘*’ network.interfaces
# Find python path’s from all minions:
sudo salt ‘*’ grains.item pythonpath –out=pprint
# With state.sls name have different execution module which needs argument as SLS file. In next steps we will use state.sls function in details.
# Create top.sls file in the already created /srv/salt folder and add the following lines (Default environment is base. In this syntax we told, * symbol is for all minions. The content of install.sls(this file must be in the same folder where placed top.sls file) file will be executed for all minions. Same for apache.sls file content must be as apache:
sudo cat /srv/salt/top.sls
base:
‘*’:
– install
– apache
sudo cat /srv/salt/install.sls
utilitler:
pkg.installed:
{% if grains[‘os’] == ‘CentOS‘ %}
– name: nload
{% elif grains[‘os’] == ‘Ubuntu‘ %}
– name: nload
{% elif grains[‘os’] == ‘FreeBSD‘ %}
– name: nload
{% endif %}
# The difference from configuration control utilities is SaltStack by default not execute state configurations. This is not by default but we can do this. With the following command we will apply all state configurations to all minions. This means state.sls call’s and execute top.sls file and top.sls calls and execute install.sls file. At the end in all minions will be installed nload package.
sudo salt ‘*’ state.highstate
# We can call and test any sls file with state.sls execution module. For example synchronize one file from saltmaster server to all minions. Add the following content to the /srv/salt/apache.sls file. In this lines we tell synchronize tesfile file from /srv/salt/fayllar folder to all minions /etc/testfile file path. The owner of file will be root and permissions will be 644:
/srv/salt$ sudo cat apache.sls
/etc/testfile:
file.managed:
– source: salt://fayllar/testfile
– user: root
– mode: 644
# Create the folder and add some lines to file placed in this folder:
/srv/salt$ sudo mkdir /srv/salt/fayllar
/srv/salt$ sudo cat /srv/salt/fayllar/testfile
dbname= db
dbpass= user
dbpass= pass
# Then send this file to all minions:
/srv/salt$ sudo salt ‘*’ state.sls apache
# For install a lot of packages to all minions in the same time, create file with /etc/srv/mypack.sls name and add the following lines. In this file we tell install packages with names mercurial and git to all minions.
/srv/salt$ sudo cat /etc/srv/mypack.sls
mypack:
pkg:
– installed
– pkgs:
– mercurial
– git
# Install selected packages to all minions:
/srv/salt$ sudo salt ‘*’ state.sls mypack
# For real-time debugging of minions we can use the following command:
sudo salt-minion -l debug
# About Pillar
Pillar gives tree structure possibility for data defining. With pillar we can control send only selected and secure data from master server to the minions.
# Sometimes you can be mistaken with grain and pillar. But remember grain’s saves data generated from minions. Information’s about CPU and OS places in grains. But pillar saves generated (on the SaltMaster server) information about minions.
# We can see the pillar information about minions with the following command:
/srv/pillar$ sudo salt ‘*’ pillar.items
# For test minions create some files and check. Firsly we create folder and needs SLS files.
/srv/pillar$ sudo mkdir -p /srv/pillar/{pkg,users}
# Add the following content to the top.sls file:
/srv/pillar$ sudo cat /srv/pillar/top.sls
base:
‘*’:
– data
– users
– pkg
# Then add needed calls path’s to the data.sls file.
/srv/pillar$ sudo cat /srv/pillar/data.sls
info: some data
# Set used data with UID:
/srv/pillar$ sudo cat /srv/pillar/users/init.sls
users:
thatch: 1000
shouse: 1001
utahdave: 1002
redbeard: 1003
#With the following example we define selected packages to the corresponding Linux/UNIX distributives:
/srv/pillar$ sudo cat /srv/pillar/pkg/init.sls
pkgs:
{% if grains[‘os_family’] == ‘CentOS’ %}
apache: httpd
vim: vim-enhanced
{% elif grains[‘os_family’] == ‘Ubuntu’ %}
apache: apache2
vim: vim
{% elif grains[‘os’] == ‘FreeBSD’ %}
mysql: mysql55-server
vim: vim
{% endif %}
# Send new pillar data’s to all minions:
/srv/pillar$ sudo salt ‘*’ saltutil.refresh_pillar
node1salt.opensource.az:
True
node4salt.opeensource.az:
True
node2salt.opensource.az:
True
node3salt.opensource.az:
True
# Salt States Sammlung
https://github.com/SS-archive/salt-states
https://github.com/nbari/my-salt
################
# Saltstack Infos/HowTos und Beispiele
##########################################
# Debian Stretch
wget -O - https://repo.saltstack.com/apt/debian/9/amd64/latest/SALTSTACK-GPG-KEY.pub | sudo apt-key add -
deb http://repo.saltstack.com/apt/debian/9/amd64/latest stretch main
# Ubuntu
deb http://repo.saltstack.com/apt/ubuntu/14.04/amd64/latest trusty main
deb http://repo.saltstack.com/apt/ubuntu/16.04/amd64/2018.3/ xenial main
## Links zum Thema Saltstack
https://wyssmann.com/introduction-to-saltstack/
https://docs.saltstack.com/en/latest/ref/modules/all/
https://docs.saltstack.com/en/latest/topics/tutorials/walkthrough.html
http://www.xenuser.org/saltstack-cheat-sheet/
https://dev-eole.ac-dijon.fr/doc/cheatsheets/saltstack.html
https://github.com/eon01/SaltStackCheatSheet
https://github.com/harkx/saltstack-cheatsheet
https://www.youtube.com/watch?v=8ytAHUGponk
# Remote Befehl ausführen
salt * cmd.run "lsb_release -d"
# System Update/Upgrade
salt '*' pkg.upgrade
# User hinzufügen
salt * user.add thorsten
# Einen öffentlichen SSH Schlüssel hinterlegen
salt '*' ssh.set_auth_key thorsten AAAAB3NZACLY..p8cow==enc='rsa' comments='[email protected]'
# Standard-Shell ändern
salt '*' user.chshell thorsten /bin/bash
# Minions holen sich alle States ab:
root@minion# salt-call state.highstate
# Master schickt alle States (top.sls)
salt '*' state.highstate
# Master schickt einen State:
salt '*' state.sls create_user
# SaltStack examples
#-------------------#
SaltStack platform or Salt is a Python-based open source configuration management software and remote execution engine. Supporting the “Infrastructure as Code” approach to deployment and cloud management, it competes primarily with Puppet, Chef, and Ansible.
We will use some of default functions., Please considerate the Link bellow about the installation of Saltstack master and nodes. and please remember all these solutions are tested in our Unixmen virtual machines, jut to be sure that every thing is working fine.
Lets start :
INSTALL AND CONFIGURE SALTSTACK SERVER IN UBUNTU X64
Show disk usage for all minions:
jamal@saltmaster:~$ sudo salt ‘*’ disk.usage
Show exist documentations for all minions:
jamal@saltmaster:~$ sudo salt ‘*’ sys.doc
Check network status to all minions:
jamal@saltmaster:~$ sudo salt ‘*’ test.ping
Look at the /etc file system for all minions:
jamal@saltmaster:~$ sudo salt ‘*’ cmd.run ‘ls -l /etc’
Get system information from all minion installed servers:
jamal@saltmaster:/srv/pillar$ sudo salt “*” grains.items
Check just FreeBSD minion:
jamal@saltmaster:/srv/pillar$ sudo salt -G ‘os:FreebSD’ test.ping
node4salt.opeensource.az:
True
pkg function automatically get minion internal functionality. This means, the pkg.install command automatically will use yum for RedHat/Centos, for apt Ubuntu/Debian and pkg for FreeBSD.
Install vim package to node4salt.opensource.az FreeBSD server as follows:
jamal@saltmaster:~$ sudo salt ‘node4salt.opensource.az’ pkg.install vim
Get information from all minions about network card names, IP address, subnets with masks and MAC address:
jamal@saltmaster:~$ sudo salt ‘*’ network.interfaces
Find python path’s from all minions:
jamal@saltmaster:~$ sudo salt ‘*’ grains.item pythonpath –out=pprint
With state.sls name have different execution module which needs argument as SLS file. In next steps we will use state.sls function in details.
Create top.sls file in the already created /srv/salt folder and add the following lines (Default environment is base. In this syntax we told, * symbol is for all minions. The content of install.sls(this file must be in the same folder where placed top.sls file) file will be executed for all minions. Same for apache.sls file content must be as apache:
jamal@saltmaster:~$ sudo cat /srv/salt/top.sls
base:
‘*’:
– install
– apache
jamal@saltmaster:~$ sudo cat /srv/salt/install.sls
utilitler:
pkg.installed:
{% if grains[‘os’] == ‘CentOS‘ %}
– name: nload
{% elif grains[‘os’] == ‘Ubuntu‘ %}
– name: nload
{% elif grains[‘os’] == ‘FreeBSD‘ %}
– name: nload
{% endif %}
The difference from configuration control utilities is SaltStack by default not execute state configurations. This is not by default but we can do this. With the following command we will apply all state configurations to all minions. This means state.sls call’s and execute top.sls file and top.sls calls and execute install.sls file. At the end in all minions will be installed nload package.
jamal@saltmaster:~$ sudo salt ‘*’ state.highstate
We can call and test any sls file with state.sls execution module. For example synchronize one file from saltmaster server to all minions. Add the following content to the /srv/salt/apache.sls file. In this lines we tell synchronize tesfile file from /srv/salt/fayllar folder to all minions /etc/testfile file path. The owner of file will be root and permissions will be 644:
jamal@saltmaster:/srv/salt$ sudo cat apache.sls
/etc/testfile:
file.managed:
– source: salt://fayllar/testfile
– user: root
– mode: 644
Create the folder and add some lines to file placed in this folder:
jamal@saltmaster:/srv/salt$ sudo mkdir /srv/salt/fayllar
jamal@saltmaster:/srv/salt$ sudo cat /srv/salt/fayllar/testfile
dbname= db
dbpass= user
dbpass= pass
Then send this file to all minions:
jamal@saltmaster:/srv/salt$ sudo salt ‘*’ state.sls apache
For install a lot of packages to all minions in the same time, create file with /etc/srv/mypack.sls name and add the following lines. In this file we tell install packages with names mercurial and git to all minions.
jamal@saltmaster:/srv/salt$ sudo cat /etc/srv/mypack.sls
mypack:
pkg:
– installed
– pkgs:
– mercurial
– git
Install selected packages to all minions:
jamal@saltmaster:/srv/salt$ sudo salt ‘*’ state.sls mypack
For real-time debugging of minions we can use the following command:
jamal@node1salt:~$ sudo salt-minion -l debug
About Pillar
Pillar gives tree structure possibility for data defining. With pillar we can control send only selected and secure data from master server to the minions.
Sometimes you can be mistaken with grain and pillar. But remember grain’s saves data generated from minions. Information’s about CPU and OS places in grains. But pillar saves generated (on the SaltMaster server) information about minions.
We can see the pillar information about minions with the following command:
jamal@saltmaster:/srv/pillar$ sudo salt ‘*’ pillar.items
For test minions create some files and check. Firsly we create folder and needs SLS files.
jamal@saltmaster:/srv/pillar$ sudo mkdir -p /srv/pillar/{pkg,users}
Add the following content to the top.sls file:
jamal@saltmaster:/srv/pillar$ sudo cat /srv/pillar/top.sls
base:
‘*’:
– data
– users
– pkg
Then add needed calls path’s to the data.sls file.
jamal@saltmaster:/srv/pillar$ sudo cat /srv/pillar/data.sls
info: some data
Set used data with UID:
jamal@saltmaster:/srv/pillar$ sudo cat /srv/pillar/users/init.sls
users:
thatch: 1000
shouse: 1001
utahdave: 1002
redbeard: 1003
With the following example we define selected packages to the corresponding Linux/UNIX distributives:
jamal@saltmaster:/srv/pillar$ sudo cat /srv/pillar/pkg/init.sls
pkgs:
{% if grains[‘os_family’] == ‘CentOS’ %}
apache: httpd
vim: vim-enhanced
{% elif grains[‘os_family’] == ‘Ubuntu’ %}
apache: apache2
vim: vim
{% elif grains[‘os’] == ‘FreeBSD’ %}
mysql: mysql55-server
vim: vim
{% endif %}
Send new pillar data’s to all minions:
jamal@saltmaster:/srv/pillar$ sudo salt ‘*’ saltutil.refresh_pillar
node1salt.opensource.az:
True
node4salt.opeensource.az:
True
node2salt.opensource.az:
True
node3salt.opensource.az:
True
# Minion Installers
On Windows:
PS C:\ > $name = "win_"+$(hostname)+"_"+$(Get-Date -Format s)
PS C:\ > Salt-Minion-x64.exe /S /master=10.0.0.2 /minion-name=$name /start-service=1
On Linux w/ apt-get:
$ apt-get install salt-minion salt-common
$ wget http://10.0.0.2/minion
$ mv ./minion /etc/salt/minion
$ sudo service salt-minion start
Or install from a script:
$ wget http://10.0.0.2/saltmin.sh
$ chmod +x saltmin.sh
$ NOW=$(date +"%m-%d-%YT%k:%M:%S")
$ saltmin.sh -P -I -i "linux_`hostname`_`echo $NOW`" -A 10.0.0.2
Command Execution
Show which minions that are up:
salt-run manage.up
Show minions that are down:
salt-run manage.down
Show all minions status:
salt-run manage.status
Test all minions connectivity:
salt '*' test.ping
Check if a process is running on all minions:
salt '*' ps.grep apache
Check if a file on all minions contains a string:
salt "*" file.contains /etc/password "admin"
Pull a file from a subgroup of minions:
salt "linux*" cp.push /etc/passwd
Send a file from the master to a subgroup of minions:
salt-cp "linux*" script_to_copy.py /target-dir/copy_of_script.py
Run arbitrary commands on a subgroup of minions:
salt "linux*" cmd.run "ls -lah /home/"
Get networking info from all minions:
salt '*' network.ip_addrs
More available network modules:
network.ping, network.traceroute, network.get_hostname, network.mod_hostname
Get uptime of all minions:
salt '*' status.uptime
Reboot all minions:
salt '*' system.reboot
Service status:
salt '*' service.status
salt '*' service.start httpd
salt '*' service.stop httpd
Cheat Sheet Saltstack
March 23, 2018 Adrian 0 Comments
Below a summary of important Salt commands
General
Update the fileserver cache. If no backend is provided, then the cache for all configured backends will be updated.
ZSH
salt-run fileserver.update
# Narrow fileserver backends to a subset of the enabled ones
salt-run fileserver.update backend=roots,git
salt-run fileserver.update
# Narrow fileserver backends to a subset of the enabled ones
salt-run fileserver.update backend=roots,git
Forcibly removes all caches on a minion.
ZSH
salt '*' saltutil.clear_cache
salt '*' saltutil.clear_cache
States
Passing pillar data ad hoc
ZSH
salt '*' state.apply ftpsync pillar='{"ftpusername": "test", "ftppassword": "0ydyfww3giq8"}'
salt '*' state.apply ftpsync pillar='{"ftpusername": "test", "ftppassword": "0ydyfww3giq8"}'
Return a list of files from the salt fileserver
ZSH
salt-run fileserver.file_list
# Lists only files for fileserver environment 'prod'
salt-run fileserver.file_list saltenv=prod
# Narrow fileserver backends to git only
salt-run fileserver.file_list saltenv=dev backend=git
salt-run fileserver.file_list
# Lists only files for fileserver environment 'prod'
salt-run fileserver.file_list saltenv=prod
# Narrow fileserver backends to git only
salt-run fileserver.file_list saltenv=dev backend=git
Apply a state or states to
ZSH
# apply all configured states
salt '*' state.apply
# Custom Pillar values, passed as a dictionary of key-value pairs
salt '*' state.apply test pillar='{"foo": "bar"}'
# Exclude specific states from execution
salt '*' state.apply exclude="[{'id': 'id_to_exclude'}, {'sls': 'sls_to_exclude'}]"
# apply all configured states
salt '*' state.apply
# Custom Pillar values, passed as a dictionary of key-value pairs
salt '*' state.apply test pillar='{"foo": "bar"}'
# Exclude specific states from execution
salt '*' state.apply exclude="[{'id': 'id_to_exclude'}, {'sls': 'sls_to_exclude'}]"
Pillars
We are going to use the Salt pillar value we just configured, so let’s first refresh Salt pillar data on all minions:
ZSH
salt '*' saltutil.refresh_pillar
salt '*' saltutil.refresh_pillar
Grains
Available grains can and grain values can be listed
ZSH
# list grains
salt '*' grains.ls
# list grains data
salt '*' grains.items
# list grains
salt '*' grains.ls
# list grains data
salt '*' grains.items
List values for a specific grain for all minions
ZSH
salt '*' grains.get os
salt '*' grains.get os
https://github.com/harkx/saltstack-cheatsheet
SaltStack Cheat Sheet .. My collection of often used commands on my Salt master.
This list is partly inspired by the fine lists on:
http://www.xenuser.org/saltstack-cheat-sheet/
https://github.com/saltstack/salt/wiki/Cheat-Sheet
Table of Contents generated with DocToc
SaltStack Cheat Sheet
First things first : Documentation
Documentation on the system
Documentation on the web
Minions
Minion status
Target minion with state files
Grains
Jobs in Salt
Sysadmin specific
System and status
Packages
Check status of a service and manipulate services
Network
Salt Cloud
Documentation
This is important because the help system is very good.
Documentation on the system
salt '*' sys.doc # output sys.doc (= all documentation)
salt '*' sys.doc pkg # only sys.doc for pkg module
salt '*' sys.doc network # only sys.doc for network module
salt '*' sys.doc system # only sys.doc for system module
salt '*' sys.doc status # only sys.doc for status module
Documentation on the web
SaltStack documentation: http://docs.saltstack.com/en/latest/
Salt-Cloud: http://docs.saltstack.com/en/latest/topics/cloud/
Jobs: http://docs.saltstack.com/en/latest/topics/jobs/
Minions
Minion status
You can also use several commands to check if minions are alive and kicking but I prefer manage.status/up/down.
salt-run manage.status # What is the status of all my minions? (both up and down)
salt-run manage.up # Any minions that are up?
salt-run manage.down # Any minions that are down?
salt-run manage.alived # Show all alive minions
salt '*' test.version # Display salt version
salt '*' test.ping # Use test module to check if minion is up and responding.
# (Not an ICMP ping!)
Target minion with state files
Apply a specific state file to a (group of..) minion(s). Do not use the .sls extension. (just like in the state files!)
salt '*' state.sls mystatefile # mystatefile.sls will be applied to *
salt 'minion1' state.sls prod.somefile # prod/somefile.sls will be applied to minion1
Grains
List all grains on all minions
salt '*' grains.ls
Look at a single grains item to list the values.
salt '*' grains.item os # Show the value of the OS grain for every minion
salt '*' grains.item roles # Show the value of the roles grain for every minion
Manipulate grains.
salt 'minion1' grains.setval mygrain True # Set mygrain to True (create if it doesn't exist yet)
salt 'minion1' grains.delval mygrain # Delete the value of the grain
Jobs in Salt
Some jobs operations that are often used. (http://docs.saltstack.com/en/latest/topics/jobs/)
salt-run jobs.active # get list of active jobs
salt-run jobs.list_jobs # get list of historic jobs
salt-run jobs.lookup_jid <job id number> # get details of this specific job
Sysadmin specific
Some stuff that is specifically of interest for sysadmins.
System and status
salt 'minion-x-*' system.reboot # Let's reboot all the minions that match minion-x-*
salt '*' status.uptime # Get the uptime of all our minions
Packages
salt '*' pkg.list_upgrades # get a list of packages that need to be upgrade
salt '*' pkg.upgrade # Upgrades all packages via apt-get dist-upgrade (or similar)
salt '*' pkg.version bash # get current version of the bash package
salt '*' pkg.install bash # install or upgrade bash package
salt '*' pkg.install bash refresh=True # install or upgrade bash package but
# refresh the package database before installing.
Check status of a service and manipulate services
salt '*' service.status <service name>
salt '*' service.available <service name>
salt '*' service.start <service name>
salt '*' service.restart <service name>
salt '*' service.stop <service name>
Network
Do some network stuff on your minions.
salt 'minion1' network.ip_addrs # Get IP of your minion
salt 'minion1' network.ping <hostname> # Ping a host from your minion
salt 'minion1' network.traceroute <hostname> # Traceroute a host from your minion
salt 'minion1' network.get_hostname # Get hostname
salt 'minion1' network.mod_hostname # Modify hostname
Salt Cloud
Salt Cloud is used to provision virtual machines in the cloud. (surprise!) (http://docs.saltstack.com/en/latest/topics/cloud/)
salt-cloud -p profile_do my-vm-name -l debug # Provision using profile_do as profile
# and my-vm-name as the virtual machine name while
# using the debug option.
salt-cloud -d my-vm-name # destroy the my-vm-name virtual machine.
salt-cloud -u # Update salt-bootstrap to latest develop version on GitHub.
https://github.com/eon01/SaltStackCheatSheet
SaltStackCheatSheet
This code is a part from "SaltStack For DevOps" Book : https://leanpub.com/saltstackfordevops/
Official website: http://saltstackfordevops.com
SaltStack For DevOps
Installing SaltStack - Ubuntu 14.*
wget -O - https://repo.saltstack.com/apt/ubuntu/ubuntu14/latest/SALTSTACK-GPG-KEY.pub | sudo apt-key add -
echo 'deb http://repo.saltstack.com/apt/ubuntu/ubuntu14/latest trusty main' | sudo tee -a /etc/apt/sources.list
sudo apt-get update
# Master installation
apt-get install salt-master
# Minion installation
apt-get install salt-minion
# Salt ssh installation
apt-get install salt-ssh
# Salt syndic installation
apt-get install salt-syndic
# Salt API installation
apt-get install salt-api
Bootstrapping Salt Minion
curl -L https://bootstrap.saltstack.com -o install_salt.sh && sudo sh install_salt.sh
Salt Key Management
# Listing Salt requests
salt-key -L
# Accepting all requests
salt-key -A
# Accepting a single request (from myNode)
salt-key -a myNode
# Removing the key of a Salt 'myNode' Minion
salt-key -d minion_id
Debugging
# Debugging the master
salt-master -l debug
# Debugging the minion
salt-minion -l debug
# Restarting the minion without cache
stop master/minion
rm -rf /var/cache/salt
start master/minion
SaltStack Documentation
# Viewing all the documentation
salt '*' sys.doc
# Viewing a module documentation
salt '*' sys.doc module_name
#Examples:
salt '*' sys.doc status
salt '*' sys.doc pkg
salt '*' sys.doc network
salt '*' sys.doc system
salt '*' sys.doc cloud
# Viewing a function documentation
salt '*' sys.doc module_name function_name
# Examples:
salt '*' sys.doc auth django
salt '*' sys.doc sdb sqlite3
SaltStack Modules And Functions
salt '*' sys.list_modules
salt '*' sys.list_functions
Compound Matchers
Letter Match Type Example Alt Delimiter?]
G Grains glob G@os:Ubuntu Yes
E PCRE Minion ID E@web\d+.(dev|qa|prod).loc No
P Grains PCRE P@os:(RedHat|Fedora|CentOS) Yes
L List of minions [email protected],minion3.domain.com or bl*.domain.com No
I Pillar glob I@pdata:foobar Yes
J Pillar PCRE J@pdata:^(foo|bar)$ Yes
S Subnet/IP address [email protected]/24 or [email protected] No
R Range cluster R@%foo.bar No
Other examples:
# Examples taken from: https://docs.saltstack.com/en/latest/topics/targeting/compound.html
# Joining
salt -C 'webserv* and G@os:Debian or E@web-dc1-srv.*' test.ping
salt -C '( ms-1 or G@id:ms-3 ) and G@id:ms-3' test.ping
# Excluding
salt -C 'not web-dc1-srv' test.ping
Upgrades & Versions
#
# Listing upgrades
salt '*' pkg.list_upgrades
# Upgrading
salt '*' pkg.upgrade
# List the packages currently installed as a dict
salt '*' pkg.list_pkgs versions_as_list=True
# Refresh the pkgutil repo database
salt '*' pkgutil.refresh_db
# Check the version of a package
salt '*' pkgutil.version mongodb
Packages Manipulation
# Installation
salt '*' pkg.install apache2
# Latest version installation
salt '*' pkgutil.latest_version mysql-common
# Removing package(s)
salt '*' pkg.remove vim
# Purging package(s)
salt '*' pkg.purge apache2 mysql-server
Reboot & Uptime
# Reboot
salt '*' system.reboot
#Uptime
salt '*' status.uptime
Using Grains
# Syncing grains
salt '*' saltutil.sync_grains
# Available grains can be listed by using the ‘grains.ls’ module:
salt '*' grains.ls
# Grains data can be listed by using the ‘grains.items’ module:
salt '*' grains.items
# Grains have values that could be called via ‘grains.get <grain_name>’ (path is the name of a grain)
salt '*' grains.get path
Syncing Data
# Syncing grains
salt '*' saltutil.sync_grains
# Syncing everything from grains to modules, outputters, renderers, returners, states and utils.
salt '*' saltutil.sync_all
Running System Commands
salt "*" cmd.run "ls -lrth /data"
salt "*" cmd.run "df -kh /data"
salt "*" cmd.run "du -sh /data"
Working With Services
# Apache example
# Checking if service is available
salt '*' service.available apache2
# Manipulating Apache2 service
salt '*' service.status apache2
salt '*' service.start apache2
salt '*' service.restart apache2
salt '*' service.stop apache2
Network Management
# Get IP of your minion
salt '*' network.ip_addrs
# Ping a host from your minion
salt '*' network.ping localhost
# Traceroute a host from your minion
salt '*' network.traceroute localhost
# Get hostname
salt '*' network.get_hostname
# Modify hostname to 'myNode'
salt '*' network.mod_hostname myNode
# Information on all of the running TCP connections
salt '*' network.active_tcp
# Return the arp table from the minion
salt '*' network.arp
# Test connectivity
salt '*' network.connect google-public-dns-a.google.com port=53 proto=udp timeout=3
# Get default route
salt '*' network.default_route
# Execute dig
salt '*' network.dig eon01.com
# Get the MAC addres of eth0 interface
salt '*' network.hw_addr eth0
# Get the inet addres of eth1 interface
salt '*' network.interface eth1
# Get the IP addres of tun interface
salt '*' network.interface_ip tun
Working With HTTP Requests
# Get the html source code of a page
salt-run http.query http://eon01.com text=true
# Get the header of a page
salt-run http.query http://eon01.com headers=true
# Get the response code from a web server
salt-run http.query http://eon01.com status=true
# Sending a post request
salt '*' http.query http://domain.com/ method=POST params='key1=val1&key2=val2'
#
Job Management
# List active jobs
salt-run jobs.active
# List all jobs with the id and other information
salt-run jobs.list_jobs
# List multiple information about the job with the id:20151101225221651308 like the result output
salt-run jobs.lookup_jid 20151101225221651308
# Kill the job with the id:20151101225221651308
salt 'server' saltutil.kill_job 20151101225221651308
Scheduling Feature
# Schedule a job called "scheduled_job"
salt '*' schedule.add scheduled_job function='cmd.run' job_args="['']" seconds=10
# Enable the job
salt '*' schedule.enable_job scheduled_job
# Disable the job
salt '*' schedule.disable_job scheduled_job
Working With SLS
salt '*' state.show_sls
Testing States
salt '*' state.highstate test=True
salt '*' state.sls test=True
salt '*' state.single test=True
Load testing
# Starting 20 minions
wget https://raw.githubusercontent.com/saltstack/salt/develop/tests/minionswarm.py; python minionswarm.py -m 20 --master salt-master;
State Declaration Structure
# Source: https://docs.saltstack.com/en/latest/ref/states/highstate.html#state-declaration
# Standard declaration
<ID Declaration>:
<State Module>:
- <Function>
- <Function Arg>
- <Function Arg>
- <Function Arg>
- <Name>: <name>
- <Requisite Declaration>:
- <Requisite Reference>
- <Requisite Reference>
# Inline function and names
<ID Declaration>:
<State Module>.<Function>:
- <Function Arg>
- <Function Arg>
- <Function Arg>
- <Names>:
- <name>
- <name>
- <name>
- <Requisite Declaration>:
- <Requisite Reference>
- <Requisite Reference>
# Multiple states for single id
<ID Declaration>:
<State Module>:
- <Function>
- <Function Arg>
- <Name>: <name>
- <Requisite Declaration>:
- <Requisite Reference>
<State Module>:
- <Function>
- <Function Arg>
- <Names>:
- <name>
- <name>
- <Requisite Declaration>:
- <Requisite Reference>
SaltStack Github Repositories
Django with SaltStack https://github.com/wunki/django-salted
Salt GUI pad https://github.com/tinyclues/saltpad
Openstack automation with SaltStack https://github.com/CSSCorp/openstack-automation
A curated collection of working salt states and configurations for use in your saltstack setup. https://github.com/saltops/saltmine
These are all of the configuration files needed to built a Wordpress development environment with Vagrant, Virtual Box and SaltStack https://github.com/paulehr/saltstack-wordpress
Java bindings for the SaltStack API https://github.com/SUSE/saltstack-netapi-client-java
Vim snippets for SaltStack states files https://github.com/StephenPCG/vim-snippets-salt
Metrics for SaltStack https://github.com/pengyao/salt-metrics
Salt GUI https://github.com/saltstack/halite
#==============================##==============================#
# CMD SALTSTACK #
#==============================##==============================#
Cheatsheets are an excellent complement to other information sources like Linux man-pages, Linux help, or How-To’s and tutorials, as they provide compact and easily accessible information. While man-pages and detailed tutorials often contain comprehensive explanations and extensive guides, cheatsheets summarize the most important options forthe command saltstack in a clear format. This allows users to quickly access the needed information for saltstack without having to sift through lengthy texts. Especially in stressful situations or for recurring tasks, cheatsheets for saltstack are a valuable resource to work efficiently and purposefully.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
█║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌
██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗███████╗██████╗
████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
╚██╔═██╔╝██║ ██║██║ ██║ ╚███╔╝ █████╗ ██║ ██║
████████╗██║ ██║██║ ██║ ██╔██╗ ██╔══╝ ██║ ██║
╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═════╝
█║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
2 - File System Check
▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁
Linux command-line file system check programs are essential tools for verifying and repairing file systems. These programs scan the file system for errors and inconsistencies, ensuring data integrity and preventing data loss. They are crucial for maintaining a healthy and reliable storage environment, especially after unexpected shutdowns or hardware failures.
One of the primary functions of file system check programs is to detect and fix errors in the file system’s metadata, such as incorrect file pointers, orphaned files, and directory structure issues. By addressing these errors, the programs help maintain the file system’s overall stability and performance. Regular file system checks can prevent minor issues from escalating into major problems that could lead to data corruption or loss.
These programs also provide detailed reports on the file system’s health, including information about bad sectors, disk usage, and potential issues that may require further attention. Administrators can use this information to make informed decisions about system maintenance and upgrades. Additionally, file system check programs often include options for running checks in read-only mode, allowing administrators to assess the file system’s condition without making any changes.
Overall, Linux command-line file system check programs are indispensable for effective system administration. They ensure that file systems remain in good working order, safeguarding data and maintaining system performance. Whether used as part of routine maintenance or in response to specific issues, these tools play a vital role in keeping Linux systems running smoothly and reliably.
2.1 - 🖥️btrfs
➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the btrfs command with important options and switches using examples.
▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁
# ██████╗ ████████╗██████╗ ███████╗███████╗
# ██╔══██╗╚══██╔══╝██╔══██╗██╔════╝██╔════╝
# ██████╔╝ ██║ ██████╔╝█████╗ ███████╗
# ██╔══██╗ ██║ ██╔══██╗██╔══╝ ╚════██║
# ██████╔╝ ██║ ██║ ██║██║ ███████║
# ╚═════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚══════╝
# Create a btrfs file system on /dev/sdb, /dev/sdc, and /dev/sdd
mkfs.btrfs /dev/sdb /dev/sdc /dev/sdd
# btrfs with just one hard drive, metadata not redundant
# (this is danegerous: if your metadata is lost, your data is lost as well)
mkfs.btrfs -m single /dev/sdb
# data to be redundant and metadata to be non-redundant:
mkfs.btrfs -m raid0 -d raid1 /dev/sdb /dev/sdc /dev/sdd
# both data and metadata to be redundan
mkfs.btrfs -d raid1 /dev/sdb /dev/sdc /dev/sdd
# To get a list of all btrfs file systems
btrfs filesystem show
# detailed df for a fileesystem (mounted in /mnt)
btrfs filesystem df /mnt
# resize btrfs online (-2g decreases, +2g increases)
btrfs filesystem resize -2g /mnt
# use maximum space
btrfs filesystem resize max /mnt
# add new device to a filesystem
btrfs device add /dev/sdf /mnt
# remove devices from a filesystem
btrfs device delete missing /mnt
# create the subvolume /mnt/sv1 in the /mnt volume
btrfs subvolume create /mnt/sv1
# list subvolumes
btrfs subvolume list /mnt
# mount subvolume without mounting the main filesystem
mount -o subvol=sv1 /dev/sdb /mnt
# delete subvolume
btrfs subvolume delete /mnt/sv1
# taking snapshot of a subvolume
btrfs subvolume snapshot /mnt/sv1 /mnt/sv1_snapshot
# taking snapshot of a file (copy file by reference)
cp --reflink /mnt/sv1/test1 /mnt/sv1/test3
# convert ext3/ext4 to btrfs
btrfs-convert /dev/sdb1
# convert btrfs to ext3/ext4
btrfs-convert -r /dev/sdb1
Cheatsheets are an excellent complement to other information sources like Linux man-pages, Linux help, or How-To’s and tutorials, as they provide compact and easily accessible information. While man-pages and detailed tutorials often contain comprehensive explanations and extensive guides, cheatsheets summarize the most important options forthe command btrfs in a clear format. This allows users to quickly access the needed information for btrfs without having to sift through lengthy texts. Especially in stressful situations or for recurring tasks, cheatsheets for btrfs are a valuable resource to work efficiently and purposefully.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
█║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌
██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗███████╗██████╗
████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
╚██╔═██╔╝██║ ██║██║ ██║ ╚███╔╝ █████╗ ██║ ██║
████████╗██║ ██║██║ ██║ ██╔██╗ ██╔══╝ ██║ ██║
╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═════╝
█║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
2.2 - 🖥️diskutil
➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the diskutil command with important options and switches using examples.
▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁
# ██████╗ ██╗███████╗██╗ ██╗██╗ ██╗████████╗██╗██╗
# ██╔══██╗██║██╔════╝██║ ██╔╝██║ ██║╚══██╔══╝██║██║
# ██║ ██║██║███████╗█████╔╝ ██║ ██║ ██║ ██║██║
# ██║ ██║██║╚════██║██╔═██╗ ██║ ██║ ██║ ██║██║
# ██████╔╝██║███████║██║ ██╗╚██████╔╝ ██║ ██║███████╗
# ╚═════╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝
# diskutil
# Utility to manage local disks and volumes (Mac OS X)
# List all currently available disks, partitions and mounted volumes:
diskutil list
# Repair the file system data structures of a volume:
diskutil repairVolume /dev/diskX
# Unmount a volume:
diskutil unmountDisk /dev/diskX
# Eject a CD/DVD (unmount first):
diskutil eject /dev/disk1
Cheatsheets are an excellent complement to other information sources like Linux man-pages, Linux help, or How-To’s and tutorials, as they provide compact and easily accessible information. While man-pages and detailed tutorials often contain comprehensive explanations and extensive guides, cheatsheets summarize the most important options forthe command diskutil in a clear format. This allows users to quickly access the needed information for diskutil without having to sift through lengthy texts. Especially in stressful situations or for recurring tasks, cheatsheets for diskutil are a valuable resource to work efficiently and purposefully.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
█║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌
██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗███████╗██████╗
████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
╚██╔═██╔╝██║ ██║██║ ██║ ╚███╔╝ █████╗ ██║ ██║
████████╗██║ ██║██║ ██║ ██╔██╗ ██╔══╝ ██║ ██║
╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═════╝
█║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
2.3 - 🖥️dumpe2fs
➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the dumpe2fs command with important options and switches using examples.
▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁
# ██████╗ ██╗ ██╗███╗ ███╗██████╗ ███████╗███████╗███████╗
# ██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██╔════╝██╔════╝
# ██║ ██║██║ ██║██╔████╔██║██████╔╝█████╗ █████╗ ███████╗
# ██║ ██║██║ ██║██║╚██╔╝██║██╔═══╝ ██╔══╝ ██╔══╝ ╚════██║
# ██████╔╝╚██████╔╝██║ ╚═╝ ██║██║ ███████╗██║ ███████║
# ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚══════╝╚═╝ ╚══════╝
# Dump information about ext2/3/4 file systems
# Begins with info on Mount path, Inode count etc.
# Then lists the block group information - free inodes etc.
dumpe2fs /dev/sdb1 | less
# Print the blocks which are reserved as bad in the filesystem
dumpe2fs -b /dev/sda2
# Use the block superblock when examining the filesystem
dumpe2fs -o superblock=superblock /dev/sda1
# Use blocks of blocksize bytes when examining the filesystem.
dumpe2fs -o blocksize=blocksize /dev/sda1
# Force dumpe2fs to display a filesystem
dumpe2fs -f /dev/sda1
# Only display the superblock information
dumpe2fs -h
# Display the filesystem data from an image file created by e2image
dumpe2fs -i
# Print the detailed group information block numbers in hexadecimal format
dumpe2fs -x
Cheatsheets are an excellent complement to other information sources like Linux man-pages, Linux help, or How-To’s and tutorials, as they provide compact and easily accessible information. While man-pages and detailed tutorials often contain comprehensive explanations and extensive guides, cheatsheets summarize the most important options forthe command dumpe2fs in a clear format. This allows users to quickly access the needed information for dumpe2fs without having to sift through lengthy texts. Especially in stressful situations or for recurring tasks, cheatsheets for dumpe2fs are a valuable resource to work efficiently and purposefully.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
█║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌
██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗███████╗██████╗
████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
╚██╔═██╔╝██║ ██║██║ ██║ ╚███╔╝ █████╗ ██║ ██║
████████╗██║ ██║██║ ██║ ██╔██╗ ██╔══╝ ██║ ██║
╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═════╝
█║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
2.4 - 🖥️export
➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the export command with important options and switches using examples.
▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁
# ███████╗██╗ ██╗██████╗ ██████╗ ██████╗ ████████╗
# ██╔════╝╚██╗██╔╝██╔══██╗██╔═══██╗██╔══██╗╚══██╔══╝
# █████╗ ╚███╔╝ ██████╔╝██║ ██║██████╔╝ ██║
# ██╔══╝ ██╔██╗ ██╔═══╝ ██║ ██║██╔══██╗ ██║
# ███████╗██╔╝ ██╗██║ ╚██████╔╝██║ ██║ ██║
# ╚══════╝╚═╝ ╚═╝╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝
#==============================#
# CMD EXPORT
#==============================##==============================#
export LESS='-sCmqPm--Less--(?eEND:%pb\%.)'
# Make less more like more, but still more than more. Percent of file in prompt, etc.
export LESS="-S -j10 -i"
# This environment variable will invoke 'less' with these options when it is used. Like when viewing a man page.
export HISTSIZE=0
# Life is too short to run the same command twice.
# History in Tag.Monat.Jahr Zeit
export HISTTIMEFORMAT="%d.%m.%y %T "
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
export LC_CTYPE="en_US.UTF-8"
export LC_NUMERIC="en_US.UTF-8"
export LC_TIME="en_US.UTF-8"
export LC_COLLATE="en_US.UTF-8"
export LC_MONETARY="en_US.UTF-8"
export LC_MESSAGES="en_US.UTF-8"
export LC_PAPER="en_US.UTF-8"
export LC_NAME="en_US.UTF-8"
export LC_ADDRESS="en_US.UTF-8"
export LC_TELEPHONE="en_US.UTF-8"
export LC_MEASUREMENT="en_US.UTF-8"
export LC_IDENTIFICATION="en_US.UTF-8"
export LC_ALL=en_US.UTF-8
# coloured shell prompt
# This coloured prompt will show: username in green, grey "@" sign, hostname in red, current directory in yellow, typed commands in green.
export PS1="\e[1;32m\u\e[0m@\e[1;31m\h\e[0m\e[1;33m\w:#> \e[1;32m"
# Get streamed FLV from Chrome with lsof
export psid=$(pgrep -f libflashplayer.so); cp /proc/$psid/fd/$(lsof -p $psid | grep eleted | awk {' print $4 '} | sed -e "s/[a-z]//g") saved.flv
# Explanation: first get the process id of the chome browser process which runs the flashplayer export it to a variable to be used later. Then we get in subshell the filedescriptor which is marked deleted and construct the /proc path for the in memory fileimage and copy it to the file named saved.flv
# Limitations: IMPORTANT: only one video should be open to play in chrome
export PROMPT_COMMAND="[ \$(date +%m%d) -eq "0401" ] && sleep 0.\$((\$RANDOM%7 + 1))"
# April Fool's prep: Put a little random delay in someone's terminal that will activate only on April 1st.
export ROSEPARITYBIT=0
export REPORTTIME=60
# ZSH, the next logical step for any serious *nix sysadmin.
# Say how long a command took, if it took more than 60 seconds.
export BIN=`which nmap` && sudo setcap cap_net_raw,cap_net_admin+eip $BIN && sudo chown root $BIN && sudo chmod u+s $BIN
# Set pcap & SUID Bit for priv. network programs (like nmap)
#==============================##==============================#
# CMD export #
#==============================##==============================#
Cheatsheets are an excellent complement to other information sources like Linux man-pages, Linux help, or How-To’s and tutorials, as they provide compact and easily accessible information. While man-pages and detailed tutorials often contain comprehensive explanations and extensive guides, cheatsheets summarize the most important options forthe command export in a clear format. This allows users to quickly access the needed information for export without having to sift through lengthy texts. Especially in stressful situations or for recurring tasks, cheatsheets for export are a valuable resource to work efficiently and purposefully.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
█║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌
██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗███████╗██████╗
████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
╚██╔═██╔╝██║ ██║██║ ██║ ╚███╔╝ █████╗ ██║ ██║
████████╗██║ ██║██║ ██║ ██╔██╗ ██╔══╝ ██║ ██║
╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═════╝
█║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
2.5 - 🖥️fdisk
➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the fdisk command with important options and switches using examples.
▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁
# ███████╗██████╗ ██╗███████╗██╗ ██╗
# ██╔════╝██╔══██╗██║██╔════╝██║ ██╔╝
# █████╗ ██║ ██║██║███████╗█████╔╝
# ██╔══╝ ██║ ██║██║╚════██║██╔═██╗
# ██║ ██████╔╝██║███████║██║ ██╗
# ╚═╝ ╚═════╝ ╚═╝╚══════╝╚═╝ ╚═╝
# Show partitions of only physical SCSI/SATA/SCA drives and not other things like device mapper entries.
fdisk -l /dev/sd?
# delete a partition
fdisk /dev/sda
Command (m for help): d
Partition number (1-9): XXX
#==============================##==============================#
# CMD fdisk #
#==============================##==============================#
Cheatsheets are an excellent complement to other information sources like Linux man-pages, Linux help, or How-To’s and tutorials, as they provide compact and easily accessible information. While man-pages and detailed tutorials often contain comprehensive explanations and extensive guides, cheatsheets summarize the most important options forthe command fdisk in a clear format. This allows users to quickly access the needed information for fdisk without having to sift through lengthy texts. Especially in stressful situations or for recurring tasks, cheatsheets for fdisk are a valuable resource to work efficiently and purposefully.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
█║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌
██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗███████╗██████╗
████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
╚██╔═██╔╝██║ ██║██║ ██║ ╚███╔╝ █████╗ ██║ ██║
████████╗██║ ██║██║ ██║ ██╔██╗ ██╔══╝ ██║ ██║
╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═════╝
█║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
2.6 - 🖥️hd
➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the hd command with important options and switches using examples.
▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁
# ██╗ ██╗██████╗
# ██║ ██║██╔══██╗
# ███████║██║ ██║
# ██╔══██║██║ ██║
# ██║ ██║██████╔╝
# ╚═╝ ╚═╝╚═════╝
# show hex dump of 20 bytes of /etc/passwd (skip 10 first bytes)
hd -s 10 -n 20 /etc/passwd
Cheatsheets are an excellent complement to other information sources like Linux man-pages, Linux help, or How-To’s and tutorials, as they provide compact and easily accessible information. While man-pages and detailed tutorials often contain comprehensive explanations and extensive guides, cheatsheets summarize the most important options forthe command hd in a clear format. This allows users to quickly access the needed information for hd without having to sift through lengthy texts. Especially in stressful situations or for recurring tasks, cheatsheets for hd are a valuable resource to work efficiently and purposefully.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
█║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌
██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗███████╗██████╗
████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
╚██╔═██╔╝██║ ██║██║ ██║ ╚███╔╝ █████╗ ██║ ██║
████████╗██║ ██║██║ ██║ ██╔██╗ ██╔══╝ ██║ ██║
╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═════╝
█║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
2.7 - 🖥️lvcreate
➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the lvcreate command with important options and switches using examples.
▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁
# ██╗ ██╗ ██╗ ██████╗██████╗ ███████╗ █████╗ ████████╗███████╗
# ██║ ██║ ██║██╔════╝██╔══██╗██╔════╝██╔══██╗╚══██╔══╝██╔════╝
# ██║ ██║ ██║██║ ██████╔╝█████╗ ███████║ ██║ █████╗
# ██║ ╚██╗ ██╔╝██║ ██╔══██╗██╔══╝ ██╔══██║ ██║ ██╔══╝
# ███████╗╚████╔╝ ╚██████╗██║ ██║███████╗██║ ██║ ██║ ███████╗
# ╚══════╝ ╚═══╝ ╚═════╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚═╝ ╚══════╝
# lvcreate
# Creates a logical volume in an existing volume group.
# A volume group is a collection of logical and physical volumes.
# Create a logical volume of 10 gigabytes in the volume group vg1:
lvcreate -L 10G vg1
# Create a 1500 megabyte linear logical volume named mylv in the volume group vg1:
lvcreate -L 1500 -n mylv vg1
# Create a logical volume called mylv that uses 60% of the total space in volume group vg1:
lvcreate -l 60%VG -n mylv vg1
# Create a logical volume called mylv that uses all of the unallocated space in the volume group vg1:
lvcreate -l 100%FREE -n mylv vg1
# Create a snapshot (lvsnap) from a logical volume (/dev/vgA/lv1);
# snapshot size = 10G (total size of the changes)
lvcreate -L 10G -s -n lvsnap /dev/vgA/lv1
# Clone LVM volume: test => testCopy
lvconvert --type mirror --alloc anywhere -m1 /dev/mylv/test
lvs -a -o +devices | egrep "LV|test"
# After Cpy%Sync is 100% finished:
lvconvert --splitmirrors 1 --name testCopy /dev/rootvg/test
Cheatsheets are an excellent complement to other information sources like Linux man-pages, Linux help, or How-To’s and tutorials, as they provide compact and easily accessible information. While man-pages and detailed tutorials often contain comprehensive explanations and extensive guides, cheatsheets summarize the most important options forthe command lvcreate in a clear format. This allows users to quickly access the needed information for lvcreate without having to sift through lengthy texts. Especially in stressful situations or for recurring tasks, cheatsheets for lvcreate are a valuable resource to work efficiently and purposefully.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
█║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌
██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗███████╗██████╗
████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
╚██╔═██╔╝██║ ██║██║ ██║ ╚███╔╝ █████╗ ██║ ██║
████████╗██║ ██║██║ ██║ ██╔██╗ ██╔══╝ ██║ ██║
╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═════╝
█║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
2.8 - 🖥️lvextend
➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the lvextend command with important options and switches using examples.
▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁
# ██╗ ██╗ ██╗███████╗██╗ ██╗████████╗███████╗███╗ ██╗██████╗
# ██║ ██║ ██║██╔════╝╚██╗██╔╝╚══██╔══╝██╔════╝████╗ ██║██╔══██╗
# ██║ ██║ ██║█████╗ ╚███╔╝ ██║ █████╗ ██╔██╗ ██║██║ ██║
# ██║ ╚██╗ ██╔╝██╔══╝ ██╔██╗ ██║ ██╔══╝ ██║╚██╗██║██║ ██║
# ███████╗╚████╔╝ ███████╗██╔╝ ██╗ ██║ ███████╗██║ ╚████║██████╔╝
# ╚══════╝ ╚═══╝ ╚══════╝╚═╝ ╚═╝ ╚═╝ ╚══════╝╚═╝ ╚═══╝╚═════╝
# lvextend
# Extends a logical volume in an existing volume group.
# A volume group is a collection of logical and physical volumes.
# Extend volume in volume mylv in groug vg0
# (defined by volume path /dev/vg0/mylv)
# to 12 gigabyte:
lvextend -L 12G /dev/vg0/mylv
# Extend volume in volume mylv in groug vg0
# (defined by volume path /dev/vg0/mylv)
# by 1 gigabyte:
lvextend -L +1G /dev/vg0/mylv
# Extend volume in volume mylv in groug vg0
# (defined by volume path /dev/vg0/mylv)
# to use all of the unallocated space in the volume group vg0:
lvextend -L +100%FREE /dev/vg0/mylv
# Extend ext4 filesystem after changing a logical volume
# (takes volume path as parameter):
ext2resize /dev/vg0/mylv
# Extend btrfs filesystem after changing a logical volume
# (takes the mount point as parameter, not the volume path):
btrfs filesystem resize max /mylv
# Extend xfs filesystem after changing a logical volume
# (takes the mount point as parameter, not the volume path):
xfs_growfs /mylv
# Extend jfs filesystem after changing a logical volume
# (takes the mount point as parameter, not the volume path);
# Just remount:
mount -o remount,resize /home
Cheatsheets are an excellent complement to other information sources like Linux man-pages, Linux help, or How-To’s and tutorials, as they provide compact and easily accessible information. While man-pages and detailed tutorials often contain comprehensive explanations and extensive guides, cheatsheets summarize the most important options forthe command lvextend in a clear format. This allows users to quickly access the needed information for lvextend without having to sift through lengthy texts. Especially in stressful situations or for recurring tasks, cheatsheets for lvextend are a valuable resource to work efficiently and purposefully.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
█║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌
██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗███████╗██████╗
████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
╚██╔═██╔╝██║ ██║██║ ██║ ╚███╔╝ █████╗ ██║ ██║
████████╗██║ ██║██║ ██║ ██╔██╗ ██╔══╝ ██║ ██║
╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═════╝
█║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
2.9 - 🖥️lvm
➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the lvm command with important options and switches using examples.
▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁
# ██╗ ██╗ ██╗███╗ ███╗
# ██║ ██║ ██║████╗ ████║
# ██║ ██║ ██║██╔████╔██║
# ██║ ╚██╗ ██╔╝██║╚██╔╝██║
# ███████╗╚████╔╝ ██║ ╚═╝ ██║
# ╚══════╝ ╚═══╝ ╚═╝ ╚═╝
#Exclusive Activation of a Volume Group in a Cluster
#Link --> https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/High_Availability_Add-On_Administration/s1-exclusiveactive-HAAA.html
1> vgs --noheadings -o vg_name
2> volume_list = [ "rhel_root", "rhel_home" ]
3> dracut -H -f /boot/initramfs-$(uname -r).img $(uname -r)
4> Reboot the node
5> uname -r to verify the correct initrd image
#==============================#
# CMD LVM
#==============================##==============================#
https://thomas-krenn.com/de/wiki/LVM_vergrößern
vgdisplay
lvdisplay
pvdisplay
# LVM's anschauen long
vgs
lgs
pgs
# LVM's anschauen short
lvextend -r --size +10G /dev/vg/opt
# vergrößern mit der option -r resized gleich das filesystem
lvdisplay
swapoff /dev/vg/swap
# swap aus
lvextend -L+1G /dev/vg/swap
mkswap /dev/vg/swap
swapon /dev/vg/swap
# LVM SWAP Vergrössern
pvcreate /dev/sdb /dev/sdc /dev/sdd
# To create physical volumes on top of /dev/sdb, /dev/sdc, and /dev/sdd
lvcreate -n vol_projects -L 10G vg00
# The -n option is used to indicate a name for the LV, whereas -L sets a fixed size and -l (lowercase L) is used to indicate a percentage of the remaining space in the container VG.
mkfs.ext4 /dev/vg00/vol_projects
# create a filesystem on top of it
lvreduce -L -2.5G -r /dev/vg00/vol_projects
# resizing each filesystem
lvextend -l +100%FREE -r /dev/vg00/vol_backups
# resizing each filesystem
vgextend vg00 /dev/sdd
# Adding the remaining PV from our initial setup (/dev/sdd).
blkid /dev/vg00/vol_projects
# to find out what its UUID (a non-changing attribute that uniquely identifies a formatted storage device) is
#==============================##==============================#
# CMD LVM #
#==============================##==============================#
Cheatsheets are an excellent complement to other information sources like Linux man-pages, Linux help, or How-To’s and tutorials, as they provide compact and easily accessible information. While man-pages and detailed tutorials often contain comprehensive explanations and extensive guides, cheatsheets summarize the most important options forthe command lvm in a clear format. This allows users to quickly access the needed information for lvm without having to sift through lengthy texts. Especially in stressful situations or for recurring tasks, cheatsheets for lvm are a valuable resource to work efficiently and purposefully.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
█║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌
██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗███████╗██████╗
████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
╚██╔═██╔╝██║ ██║██║ ██║ ╚███╔╝ █████╗ ██║ ██║
████████╗██║ ██║██║ ██║ ██╔██╗ ██╔══╝ ██║ ██║
╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═════╝
█║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
2.10 - 🖥️ncdu
➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the ncdu command with important options and switches using examples.
▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁
# ███╗ ██╗ ██████╗██████╗ ██╗ ██╗
# ████╗ ██║██╔════╝██╔══██╗██║ ██║
# ██╔██╗ ██║██║ ██║ ██║██║ ██║
# ██║╚██╗██║██║ ██║ ██║██║ ██║
# ██║ ╚████║╚██████╗██████╔╝╚██████╔╝
# ╚═╝ ╚═══╝ ╚═════╝╚═════╝ ╚═════╝
# Save results to file
ncdu -o ncdu.file
# Read from file
ncdu -f ncdu.file
# Save results to compressed file
ncdu -o-| gzip > ncdu.file.gz
# Read from compressed file
zcat ncdu.file.gz | ncdu -f-
#==============================##==============================#
# CMD NCDU #
#==============================##==============================#
Cheatsheets are an excellent complement to other information sources like Linux man-pages, Linux help, or How-To’s and tutorials, as they provide compact and easily accessible information. While man-pages and detailed tutorials often contain comprehensive explanations and extensive guides, cheatsheets summarize the most important options forthe command ncdu in a clear format. This allows users to quickly access the needed information for ncdu without having to sift through lengthy texts. Especially in stressful situations or for recurring tasks, cheatsheets for ncdu are a valuable resource to work efficiently and purposefully.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
█║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌
██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗███████╗██████╗
████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
╚██╔═██╔╝██║ ██║██║ ██║ ╚███╔╝ █████╗ ██║ ██║
████████╗██║ ██║██║ ██║ ██╔██╗ ██╔══╝ ██║ ██║
╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═════╝
█║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
2.11 - 🖥️parted
➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the parted command with important options and switches using examples.
▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁
# ██████╗ █████╗ ██████╗ ████████╗███████╗██████╗
# ██╔══██╗██╔══██╗██╔══██╗╚══██╔══╝██╔════╝██╔══██╗
# ██████╔╝███████║██████╔╝ ██║ █████╗ ██║ ██║
# ██╔═══╝ ██╔══██║██╔══██╗ ██║ ██╔══╝ ██║ ██║
# ██║ ██║ ██║██║ ██║ ██║ ███████╗██████╔╝
# ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚══════╝╚═════╝
# create a new MBR/msdos partition table for BIOS systems
(parted) mklabel msdos
# create a new GPT partition table for UEFI systems instead, use:
(parted) mklabel gpt
# grow a partition
(parted) resizepart ${number} ${end}
Cheatsheets are an excellent complement to other information sources like Linux man-pages, Linux help, or How-To’s and tutorials, as they provide compact and easily accessible information. While man-pages and detailed tutorials often contain comprehensive explanations and extensive guides, cheatsheets summarize the most important options forthe command parted in a clear format. This allows users to quickly access the needed information for parted without having to sift through lengthy texts. Especially in stressful situations or for recurring tasks, cheatsheets for parted are a valuable resource to work efficiently and purposefully.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
█║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌
██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗███████╗██████╗
████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
╚██╔═██╔╝██║ ██║██║ ██║ ╚███╔╝ █████╗ ██║ ██║
████████╗██║ ██║██║ ██║ ██╔██╗ ██╔══╝ ██║ ██║
╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═════╝
█║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
2.12 - 🖥️resize2fs
➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the resize2fs command with important options and switches using examples.
▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁
# ██████╗ ███████╗███████╗██╗███████╗███████╗██████╗ ███████╗███████╗
# ██╔══██╗██╔════╝██╔════╝██║╚══███╔╝██╔════╝╚════██╗██╔════╝██╔════╝
# ██████╔╝█████╗ ███████╗██║ ███╔╝ █████╗ █████╔╝█████╗ ███████╗
# ██╔══██╗██╔══╝ ╚════██║██║ ███╔╝ ██╔══╝ ██╔═══╝ ██╔══╝ ╚════██║
# ██║ ██║███████╗███████║██║███████╗███████╗███████╗██║ ███████║
# ╚═╝ ╚═╝╚══════╝╚══════╝╚═╝╚══════╝╚══════╝╚══════╝╚═╝ ╚══════╝
# resize2fs
# ext2/ext3/ext4 file system resizer
# resize filesystem up to the block device size
# make e2fsck /dev/xvdb1 before
# filesystem must be not mounted for ext2
resize2fs /dev/xvdb1
# shrink filesystem (20G is new size)
resize2fs /dev/xvdb1 20G
Cheatsheets are an excellent complement to other information sources like Linux man-pages, Linux help, or How-To’s and tutorials, as they provide compact and easily accessible information. While man-pages and detailed tutorials often contain comprehensive explanations and extensive guides, cheatsheets summarize the most important options forthe command resize2fs in a clear format. This allows users to quickly access the needed information for resize2fs without having to sift through lengthy texts. Especially in stressful situations or for recurring tasks, cheatsheets for resize2fs are a valuable resource to work efficiently and purposefully.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
█║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌
██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗███████╗██████╗
████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
╚██╔═██╔╝██║ ██║██║ ██║ ╚███╔╝ █████╗ ██║ ██║
████████╗██║ ██║██║ ██║ ██╔██╗ ██╔══╝ ██║ ██║
╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═════╝
█║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
2.13 - 🖥️tune2fs
➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the tune2fs command with important options and switches using examples.
▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁
# ████████╗██╗ ██╗███╗ ██╗███████╗██████╗ ███████╗███████╗
# ╚══██╔══╝██║ ██║████╗ ██║██╔════╝╚════██╗██╔════╝██╔════╝
# ██║ ██║ ██║██╔██╗ ██║█████╗ █████╔╝█████╗ ███████╗
# ██║ ██║ ██║██║╚██╗██║██╔══╝ ██╔═══╝ ██╔══╝ ╚════██║
# ██║ ╚██████╔╝██║ ╚████║███████╗███████╗██║ ███████║
# ╚═╝ ╚═════╝ ╚═╝ ╚═══╝╚══════╝╚══════╝╚═╝ ╚══════╝
tune2fs -m1 /dev/sda1
# Reduce the superuser reserved space on a Linux ext[234] filesystem to 1% (default is 5%). This gives you more user space because on a 8TB drive, 4% is enough to hold ~300 HD quality movies. It's recommended not to go below 1% to be safe.
#==============================##==============================#
# CMD tune2fs #
#==============================##==============================#
Cheatsheets are an excellent complement to other information sources like Linux man-pages, Linux help, or How-To’s and tutorials, as they provide compact and easily accessible information. While man-pages and detailed tutorials often contain comprehensive explanations and extensive guides, cheatsheets summarize the most important options forthe command tune2fs in a clear format. This allows users to quickly access the needed information for tune2fs without having to sift through lengthy texts. Especially in stressful situations or for recurring tasks, cheatsheets for tune2fs are a valuable resource to work efficiently and purposefully.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
█║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌
██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗███████╗██████╗
████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
╚██╔═██╔╝██║ ██║██║ ██║ ╚███╔╝ █████╗ ██║ ██║
████████╗██║ ██║██║ ██║ ██╔██╗ ██╔══╝ ██║ ██║
╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═════╝
█║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
2.14 - 🖥️xfs_repair
➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the xfs_repair command with important options and switches using examples.
▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁
# ██╗ ██╗███████╗███████╗ ██████╗ ███████╗██████╗ █████╗ ██╗██████╗
# ╚██╗██╔╝██╔════╝██╔════╝ ██╔══██╗██╔════╝██╔══██╗██╔══██╗██║██╔══██╗
# ╚███╔╝ █████╗ ███████╗ ██████╔╝█████╗ ██████╔╝███████║██║██████╔╝
# ██╔██╗ ██╔══╝ ╚════██║ ██╔══██╗██╔══╝ ██╔═══╝ ██╔══██║██║██╔══██╗
# ██╔╝ ██╗██║ ███████║███████╗██║ ██║███████╗██║ ██║ ██║██║██║ ██║
# ╚═╝ ╚═╝╚═╝ ╚══════╝╚══════╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚═╝╚═╝╚═╝ ╚═╝
# xfs_repair - repair an XFS filesystem
# rapair a XFS filesystem
xfs_repair /dev/dm-0
# last resort option:
# -L: Force Log Zeroing. zero the log even if it is dirty (contains metadata changes).
# When using this option the filesystem will likely appear to be corrupt,
# and can cause the loss of user files and/or data.
xfs_repair -v -L /dev/dm-0
Cheatsheets are an excellent complement to other information sources like Linux man-pages, Linux help, or How-To’s and tutorials, as they provide compact and easily accessible information. While man-pages and detailed tutorials often contain comprehensive explanations and extensive guides, cheatsheets summarize the most important options forthe command xfs_repair in a clear format. This allows users to quickly access the needed information for xfs_repair without having to sift through lengthy texts. Especially in stressful situations or for recurring tasks, cheatsheets for xfs_repair are a valuable resource to work efficiently and purposefully.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
█║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌
██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗███████╗██████╗
████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
╚██╔═██╔╝██║ ██║██║ ██║ ╚███╔╝ █████╗ ██║ ██║
████████╗██║ ██║██║ ██║ ██╔██╗ ██╔══╝ ██║ ██║
╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═════╝
█║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
3 - Performance Monitoring
▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁
Performance monitoring tools track and analyze the performance of a computer system. They provide insights into resource usage, such as CPU, memory, and disk I/O, helping identify bottlenecks and optimize system performance. Regular monitoring ensures that systems run efficiently and reliably. These tools also help in capacity planning and proactive maintenance.
3.1 - 🖥️dmesg
➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the dmesg command with important options and switches using examples.
▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁
██████╗ ███╗ ███╗███████╗███████╗ ██████╗
██╔══██╗████╗ ████║██╔════╝██╔════╝██╔════╝
██║ ██║██╔████╔██║█████╗ ███████╗██║ ███╗
██║ ██║██║╚██╔╝██║██╔══╝ ╚════██║██║ ██║
██████╔╝██║ ╚═╝ ██║███████╗███████║╚██████╔╝
╚═════╝ ╚═╝ ╚═╝╚══════╝╚══════╝ ╚═════╝
# Clear dmesg Buffer Logs
dmesg -c
# Display the local time and the delta in human-readable format. Conversion to the local time could be inaccurate
dmesg -e
# Print human-readable timestamps.
# 27M ./Stuff
# 808K ./Configs
# 1.1M ./comemierda
# 232M .
dmesg -T
# Human-readable output (color + reltime)
dmesg -H
dmesg -w
# dmesg: follow/wait for new kernel messages
# follow/wait for new kernel messages similar to `tail -f` available since util-linux 2.22.
dmesg -wH
# Live dmesg output in human readable format (colors, timing)
dmesg -T | tail -n20
# Show the most recent 20 lines of dmesg with the times converted to local human readable times.
dmesg -T
# Newer versions of dmesg on Linux have this nice -T option for printing the local time instead of epoch time for timestamps
# The proper way to read kernel messages in realtime.
dmesg -wx
#==============================##==============================#
# CMD dmesg #
#==============================##==============================#
Cheatsheets are an excellent complement to other information sources like Linux man-pages, Linux help, or How-To’s and tutorials, as they provide compact and easily accessible information. While man-pages and detailed tutorials often contain comprehensive explanations and extensive guides, cheatsheets summarize the most important options forthe command dmesg in a clear format. This allows users to quickly access the needed information for dmesg without having to sift through lengthy texts. Especially in stressful situations or for recurring tasks, cheatsheets for dmesg are a valuable resource to work efficiently and purposefully.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
█║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌
██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗███████╗██████╗
████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
╚██╔═██╔╝██║ ██║██║ ██║ ╚███╔╝ █████╗ ██║ ██║
████████╗██║ ██║██║ ██║ ██╔██╗ ██╔══╝ ██║ ██║
╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═════╝
█║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
3.2 - 🖥️dstat
➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the dstat command with important options and switches using examples.
▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁
# ██████╗ ███████╗████████╗ █████╗ ████████╗
# ██╔══██╗██╔════╝╚══██╔══╝██╔══██╗╚══██╔══╝
# ██║ ██║███████╗ ██║ ███████║ ██║
# ██║ ██║╚════██║ ██║ ██╔══██║ ██║
# ██████╔╝███████║ ██║ ██║ ██║ ██║
# ╚═════╝ ╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝
#==============================#
# CMD dstat
#==============================##==============================#
dstat
# The dstat is a versatile tool, that generates statistics relating to system resource.
dstat --vmstat
#
dstat -c --top-cpu -dn --top-mem
-c – cpu usage
--top-cpu – process using most CPU
-dn – disk and network stats
--top-mem – process consuming the most memory
dstat --time --cpu --mem --load --output report.csv 1 5
# Additionally, you can also store the output of dstat in a .csv file for analysis at a latter time by enabling the --output option as in the example below.
dstat --list
#
#==============================##==============================#
# CMD dstat
#==============================##==============================#
Cheatsheets are an excellent complement to other information sources like Linux man-pages, Linux help, or How-To’s and tutorials, as they provide compact and easily accessible information. While man-pages and detailed tutorials often contain comprehensive explanations and extensive guides, cheatsheets summarize the most important options forthe command dstat in a clear format. This allows users to quickly access the needed information for dstat without having to sift through lengthy texts. Especially in stressful situations or for recurring tasks, cheatsheets for dstat are a valuable resource to work efficiently and purposefully.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
█║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌
██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗███████╗██████╗
████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
╚██╔═██╔╝██║ ██║██║ ██║ ╚███╔╝ █████╗ ██║ ██║
████████╗██║ ██║██║ ██║ ██╔██╗ ██╔══╝ ██║ ██║
╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═════╝
█║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
3.3 - 🖥️free
➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the free command with important options and switches using examples.
▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁
# ███████╗██████╗ ███████╗███████╗
# ██╔════╝██╔══██╗██╔════╝██╔════╝
# █████╗ ██████╔╝█████╗ █████╗
# ██╔══╝ ██╔══██╗██╔══╝ ██╔══╝
# ██║ ██║ ██║███████╗███████╗
# ╚═╝ ╚═╝ ╚═╝╚══════╝╚══════╝
Free
The free command displays the amount of free and used memory in the system.
$ free
total used free shared buffers cached
Mem: 1800032 1355288 444744 79440 9068 216236
-/+ buffers/cache: 1129984 670048
Swap: 1832956 995076 837880
#==============================##==============================#
# CMD free #
#==============================##==============================#
Cheatsheets are an excellent complement to other information sources like Linux man-pages, Linux help, or How-To’s and tutorials, as they provide compact and easily accessible information. While man-pages and detailed tutorials often contain comprehensive explanations and extensive guides, cheatsheets summarize the most important options forthe command free in a clear format. This allows users to quickly access the needed information for free without having to sift through lengthy texts. Especially in stressful situations or for recurring tasks, cheatsheets for free are a valuable resource to work efficiently and purposefully.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
█║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌
██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗███████╗██████╗
████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
╚██╔═██╔╝██║ ██║██║ ██║ ╚███╔╝ █████╗ ██║ ██║
████████╗██║ ██║██║ ██║ ██╔██╗ ██╔══╝ ██║ ██║
╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═════╝
█║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
3.4 - 🖥️gpustat
➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the gpustat command with important options and switches using examples.
▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁
# ██████╗ ██████╗ ██╗ ██╗███████╗████████╗ █████╗ ████████╗
# ██╔════╝ ██╔══██╗██║ ██║██╔════╝╚══██╔══╝██╔══██╗╚══██╔══╝
# ██║ ███╗██████╔╝██║ ██║███████╗ ██║ ███████║ ██║
# ██║ ██║██╔═══╝ ██║ ██║╚════██║ ██║ ██╔══██║ ██║
# ╚██████╔╝██║ ╚██████╔╝███████║ ██║ ██║ ██║ ██║
# ╚═════╝ ╚═╝ ╚═════╝ ╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝
# A simple command-line script (wrapper for nvidia-smi) for querying and monitoring GPU status
# to install: pip install gpustat
# show GPU statistsics with the processes PIDs and names
gpustat -cp
Cheatsheets are an excellent complement to other information sources like Linux man-pages, Linux help, or How-To’s and tutorials, as they provide compact and easily accessible information. While man-pages and detailed tutorials often contain comprehensive explanations and extensive guides, cheatsheets summarize the most important options forthe command gpustat in a clear format. This allows users to quickly access the needed information for gpustat without having to sift through lengthy texts. Especially in stressful situations or for recurring tasks, cheatsheets for gpustat are a valuable resource to work efficiently and purposefully.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
█║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌
██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗███████╗██████╗
████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
╚██╔═██╔╝██║ ██║██║ ██║ ╚███╔╝ █████╗ ██║ ██║
████████╗██║ ██║██║ ██║ ██╔██╗ ██╔══╝ ██║ ██║
╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═════╝
█║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
3.5 - 🖥️htop
➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the htop command with important options and switches using examples.
▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁
# ██╗ ██╗████████╗ ██████╗ ██████╗
# ██║ ██║╚══██╔══╝██╔═══██╗██╔══██╗
# ███████║ ██║ ██║ ██║██████╔╝
# ██╔══██║ ██║ ██║ ██║██╔═══╝
# ██║ ██║ ██║ ╚██████╔╝██║
# ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝
# htop
#
# Display dynamic real-time information about running processes. An enhanced version of top.
# Start htop:
htop
# Start htop displaying only processes owned by given user:
htop -u user_name
# Refresh every 10 seconds
htop -d 10
# Get help about interactive commands:
?
# Inverts the sort order
I
# Trace a process (with strace)
s
Cheatsheets are an excellent complement to other information sources like Linux man-pages, Linux help, or How-To’s and tutorials, as they provide compact and easily accessible information. While man-pages and detailed tutorials often contain comprehensive explanations and extensive guides, cheatsheets summarize the most important options forthe command htop in a clear format. This allows users to quickly access the needed information for htop without having to sift through lengthy texts. Especially in stressful situations or for recurring tasks, cheatsheets for htop are a valuable resource to work efficiently and purposefully.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
█║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌
██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗███████╗██████╗
████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
╚██╔═██╔╝██║ ██║██║ ██║ ╚███╔╝ █████╗ ██║ ██║
████████╗██║ ██║██║ ██║ ██╔██╗ ██╔══╝ ██║ ██║
╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═════╝
█║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
3.6 - 🖥️nproc
➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the nproc command with important options and switches using examples.
▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁
# ███╗ ██╗██████╗ ██████╗ ██████╗ ██████╗
# ████╗ ██║██╔══██╗██╔══██╗██╔═══██╗██╔════╝
# ██╔██╗ ██║██████╔╝██████╔╝██║ ██║██║
# ██║╚██╗██║██╔═══╝ ██╔══██╗██║ ██║██║
# ██║ ╚████║██║ ██║ ██║╚██████╔╝╚██████╗
# ╚═╝ ╚═══╝╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═════╝
# The nproc command displays the number of processing units available to the current process.
# Number of CPU's in a system - This appears to do the same. Utility is verified to be present on Ubuntu and OpenSuse out-of-the-box.
nproc
1
#==============================##==============================#
# CMD NPROC #
#==============================##==============================#
Cheatsheets are an excellent complement to other information sources like Linux man-pages, Linux help, or How-To’s and tutorials, as they provide compact and easily accessible information. While man-pages and detailed tutorials often contain comprehensive explanations and extensive guides, cheatsheets summarize the most important options forthe command nproc in a clear format. This allows users to quickly access the needed information for nproc without having to sift through lengthy texts. Especially in stressful situations or for recurring tasks, cheatsheets for nproc are a valuable resource to work efficiently and purposefully.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
█║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌
██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗███████╗██████╗
████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
╚██╔═██╔╝██║ ██║██║ ██║ ╚███╔╝ █████╗ ██║ ██║
████████╗██║ ██║██║ ██║ ██╔██╗ ██╔══╝ ██║ ██║
╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═════╝
█║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
3.7 - 🖥️perf
➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the perf command with important options and switches using examples.
▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁
# ██████╗ ███████╗██████╗ ███████╗
# ██╔══██╗██╔════╝██╔══██╗██╔════╝
# ██████╔╝█████╗ ██████╔╝█████╗
# ██╔═══╝ ██╔══╝ ██╔══██╗██╔══╝
# ██║ ███████╗██║ ██║██║
# ╚═╝ ╚══════╝╚═╝ ╚═╝╚═╝
# Benchmark SQL Query -> Benchmark a SQL query against MySQL Server. The example runs the query 10 times, and you get the average runtime in the output. To ensure that the query does not get cached, use `RESET QUERY CACHE;` on top in the query file. Show Sample Output
perf stat -r 10 sh -c "mysql > /dev/null < query.sql"
Cheatsheets are an excellent complement to other information sources like Linux man-pages, Linux help, or How-To’s and tutorials, as they provide compact and easily accessible information. While man-pages and detailed tutorials often contain comprehensive explanations and extensive guides, cheatsheets summarize the most important options forthe command perf in a clear format. This allows users to quickly access the needed information for perf without having to sift through lengthy texts. Especially in stressful situations or for recurring tasks, cheatsheets for perf are a valuable resource to work efficiently and purposefully.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
█║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌
██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗███████╗██████╗
████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
╚██╔═██╔╝██║ ██║██║ ██║ ╚███╔╝ █████╗ ██║ ██║
████████╗██║ ██║██║ ██║ ██╔██╗ ██╔══╝ ██║ ██║
╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═════╝
█║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
3.8 - 🖥️ps
➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the ps command with important options and switches using examples.
▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁
# ██████╗ ███████╗
# ██╔══██╗██╔════╝
# ██████╔╝███████╗
# ██╔═══╝ ╚════██║
# ██║ ███████║
# ╚═╝ ╚══════╝
# To list every process on the system:
ps aux
# To list a process tree
ps axjf
# To list every process owned by foouser:
ps -aufoouser
# To list every process with a user-defined format:
ps -eo pid,user,command
# Exclude grep from your grepped output of ps.
# Add [] to the first letter. Ex: sshd -> [s]shd
ps aux | grep '[h]ttpd'
#==============================#
# CMD PS
#==============================##==============================#
ps -o pid,lstart,command ax
# When Apr01 just won not do, show the (long) format start time for all processes on a Linux system.
ps auxww | grep "[h]ttpd"
# Show only the processes matching httpd, ignoring the line of the grep process itself (regex trick).
ps xaw -eo pid,args,cgroup
ps k-%cpu
ps aux|sort -n -k6 -r |head
ps -LF -u user_name
# The below command outputs processes and threads of a user. The option “L” (list threads) and “-F” (Full Format Listing).
ps aux |grep ssh |grep -v grep |awk ?{print $2}? |xargs kill -9
# and even better - setup public/private keys and you could use "-i ~/.ssh/public_key" as ssh parameter, to avoid password prompt ==> then could have everything in a shell script
ps auxw | grep "[h]ttpd" | wc -l
# Count the number of web server processes running. Or use (pgrep -c httpd)
ps auxww | grep "[h]ttpd" | wc -l
# Count the number of web server processes running.
ps auxwf | grep -B8 "[g]zip"
# Show the process in a tree format, search for gzip and show 8 lines of pre-match context to see its family.
ps auxwwf | sed -n -r -e '/^.{64} \//h;/\\/H' -e '/^.{14} [8-9][0-9]\.[0-9]/{x;p}'
# Print the high CPU process's family tree.
ps auxww | tee output.log
# Use the 'tee' command to save a copy and see the output of a program at the same time.
ps -o pid,lstart,command ax
# When Apr01 just won not do, show the (long) format start time for all processes on a Linux system.
ps ax -o state -o ppid | awk '$1=="Z"{print $2}' | xargs kill -9
# Kill all #zombies on the system.
ps wu -U someuser
# An easy way of selecting the processes owned by someuser.
ps aux | awk '{if ($8=="Z") { print $2 }}'
# On Linux, print out a list of the process IDs that are in the zombie state.
ps aux|tail -n+2 |sort -nrk4 |head -$(($(tput lines)-1)) |cut -c 1-$(tput cols)
# Display top RAM using processes. Browser is probably
ps -ef | grep [p]mon | awk '{print $2}' | xargs -I {} ps eww {} | awk '{print $1 " " $5 " " $6 " " $0}' | sed 's/\(S*\) \(S*\) .*ORACLE_HOME/\1 \2/g' | cut -f1,2,3 -d" "
# the executable that started the currently running oracle databases and the ORACLE_HOME relative to each
# Show the executable that spawned the process and show the PID and ORACLE_HOME relative to the environment within which the process is running.
ps aux | awk '{if ($8 ~ "D") print $0}'
# List process in unkillable state D (iowait)
# On Linux, print the processes that are in the zombie state. Hopefully there are none.
ps auxww | awk '$8=="Z"'
ps auxwf | grep -B8 " [2]533 "
# Display process table in Linux with parent/child relationships, searching for process id 2533 and displaying the 8 lines before the matched line. The [2] part is so the grep doesn't match it's own process line.
ps aux | sort -rk 3,3 | head -n 10
# Sort processes by CPU Usage Short list about top 10 processes, sorted by CPU usage This is sample output
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 9878 2.4 0.0 944296 7588 ? Ssl Sep03 2010:47 dad
admbd 1282 1.0 0.0 64212 3984 pts/46 S+ 17:01 0:00 ssh frutillar
root 1279 0.4 0.0 64208 3984 pts/77 S+ 17:01 0:00 ssh desacloud522
root 1278 0.4 0.0 64208 3976 pts/129 S+ 17:01 0:00 ssh f1cloud4099
root 1281 0.3 0.0 82488 4524 ? S 17:01 0:00 /usr/sbin/packagekitd
root 10238 0.3 0.0 55048 8992 ? Ssl Sep03 244:21 /opt/CA/SystemEDGE/bin/sysedge -b
root 11321 0.2 0.1 278880 25168 ? Sl Sep03 170:44 splunkd -p 8089 start
root 10086 0.1 0.0 165280 12364 ? Ssl Sep03 102:49 /usr/sbin/adclient
appdyn 514 0.1 0.0 112432 2736 ? S 16:58 0:00 sshd: appdyn@pts/130
ps aux | grep ssh | grep -v grep | grep -v sshd | awk {'print $2'} | xargs -r kill -9
# Kill any lingering ssh processes - Also ignoring "sshd" server is necessary since you should not kill ssh server processes.
# Hide's the name of a process listed in the `ps` output -> The classical 'ps aux | grep' can do this with one more parameter, the '-v', with means 'NOT' to grep.
ps aux | grep -v name_you_want_to_hide
# Memory Verbrauch addiert nach Prozessname - Mithilfe folgender Codewurst kann der Memoryverbrauch nach Prozessnamen addiert aufgelistet werden:
ps -e -o comm,rss --no-heading|awk '{arr[$1]+=$2} END {for (i in arr) {printf("%15s ", i); printf("%6s \n", arr[i]);}}'|grep -v ' 0'|sort -nr -k2
# Kleine Variante - wenn wir die Hauptverbraucher ohnehin schon kennen, konzentrieren wir uns auf die:
ps -C amavisd-new,clamd,apache2,mysqld -o comm,rss --no-heading|awk '{arr[$1]+=$2} END {for (i in arr) {printf("%15s ", i); printf("%6s \n", arr[i]);}}'|grep -v ' 0'|sort -nr -k2
# Welches Kommando macht was?
ps listet die rss (resident set size) und den Namen des Prozesses
awk addiert die Felder nach Namen und formatiert die Ausgabe
grep verwirft die Einträge mit rss=0
sort sortiert absteigend nach Verbrauch
# Linux shell processes discovery - what processes doing right now
ps -e -o pid,comm,wchan=WIDE-WCHAN-COLUMN
ps ax -o state -o ppid | awk '$1=="Z"{print $2}' | xargs kill -9
# Kill all #zombies on the system.
ps auxww | tee output.log
# Use the 'tee' command to save a copy and see the output of a program at the same time.
ps aux | awk '{if ($8=="Z") { print $2 }}'
# On Linux, print out a list of the process IDs that are in the zombie state.
# List open processes ordered by it is number of open files
# Explanation: Combines ps, lsof, and sort in the ways you might expect to produce the intended outcome.
ps -ef |awk '{ print $2 }' \ |tail -n +2 \ |while read pid; do echo "$pid $(lsof -p $pid |wc -l)"; done \ |sort -r -n -k 2 \ |while read pid count; do echo "$pid $count $(ps -o command= -p $pid)"; done
# Top 10 Memory Processes (reduced output to applications and %usage only)
# sort bei User
ps jax --sort=uid,-ppid,+pid
# output sort by memory (RAM)
ps aux --sort -rss
ps aux | sort -rk 4,4 | head -n 10 | awk '{print $4,$11}'
# Sample output
# savage@mastervoid~> ps aux | sort -rk 4,4 | head -n 10 | awk '{print $4,$11}'
# %MEM COMMAND
# 4.8 /usr/lib/firefox-esr/firefox-esr
# 4.8 firefox-esr
# 3.0 /usr/lib/firefox-esr/firefox-esr
# 2.8 /usr/lib/firefox-esr/firefox-esr
# 2.8 /usr/lib/firefox-esr/firefox-esr
# 2.1 /app/extra/share/spotify/spotify
# 1.5 /app/extra/share/spotify/spotify
# 1.2 /usr/share/atom/atom
# 0.9 /usr/share/atom/atom
# Top 10 Memory Processes - It displays the top 10 processes sorted by memory usage
ps aux | sort -rk 4,4 | head -n 10
# Sample output
# USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
# r00t 31878 24.1 3.3 3138164 546484 ? Sl 11:45 24:06 pmdtm -PR -gmh alsea -gmp 6015 -guid 6b122687-8aeb-481a-a33f-867a59c14fee -rst 180 -s ...
# r00t 2639 0.0 3.2 1626772 531944 ? Sl Jun20 44:22 /u01/home/app/r00t/Informatica/9.5.1/java/bin/java -Dfile.encoding=UTF-8 -d64 -Xmx512M ...
# r00t 27794 9.0 2.1 2809284 344388 ? Sl 10:43 14:34 pmdtm -PR -gmh alsea -gmp 6015 -guid 6b122687-8aeb-481a-a33f-867a59c14fee -rst 180 -s ...
# r00t 13796 0.2 2.1 3406808 349972 ? Sl Jun19 337:10 /u01/home/app/r00t/Informatica/9.5.1/java/bin/java -ea -Djava.awt.headless=true ... -Xmx2048m ...
# r00t 32222 101 19.9 4805632 3262688 ? Sl 11:55 90:33 pmdtm -PR -gmh alsea -gmp 6015 -guid 6b122687-8aeb-481a-a33f-867a59c14fee -rst 180 -s ...
# r00t 14036 0.3 1.6 2841340 269712 ? Sl Jun19 449:57 /u01/home/app/r00t/Informatica/9.5.1/server/bin/pmrepagent - RG9tYWluX0RFVlRFU1Q= RGVzYXJyb2xsbw== ...
# ctmagent 6176 0.0 1.6 4804504 276240 ? Sl Mar29 165:32 ./JRE/bin/java -classpath exe/ctminf.jar com.bmc.ctm.cminf.Start start 4
# r00t 14218 0.1 1.5 1927368 260112 ? Sl Jun19 181:00 /u01/home/app/r00t/Informatica/9.5.1/server/bin/pmserver RG9tYWluX0RFVlRFU1Q= SVNfRGVzYXJyb2xsbw== ...
# r00t 13963 0.1 1.1 1356460 195172 ? Sl Jun19 168:50 /u01/home/app/r00t/Informatica/9.5.1/java/bin/java -XX:GCTimeRatio=9 -XX:MaxPermSize=128m -Xmx512M ...
# you can monitor a process on Linux - example:
while ps -p`pidof vim` &>/dev/null; do command1; done ; command2
# command1: do something while vim is running
# command2: do something after vim has exited
# Beendet Prozesse
sudo ps S | awk '{ print $ 1; }' | grep -E '[0-9]' | sort -R | sed -n 'p;n' | xargs kill -9
#==============================##==============================#
# CMD PS
#==============================##==============================#
Cheatsheets are an excellent complement to other information sources like Linux man-pages, Linux help, or How-To’s and tutorials, as they provide compact and easily accessible information. While man-pages and detailed tutorials often contain comprehensive explanations and extensive guides, cheatsheets summarize the most important options forthe command ps in a clear format. This allows users to quickly access the needed information for ps without having to sift through lengthy texts. Especially in stressful situations or for recurring tasks, cheatsheets for ps are a valuable resource to work efficiently and purposefully.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
█║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌
██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗███████╗██████╗
████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
╚██╔═██╔╝██║ ██║██║ ██║ ╚███╔╝ █████╗ ██║ ██║
████████╗██║ ██║██║ ██║ ██╔██╗ ██╔══╝ ██║ ██║
╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═════╝
█║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
3.9 - 🖥️pstree
➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the pstree command with important options and switches using examples.
▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁
# ██████╗ ███████╗████████╗██████╗ ███████╗███████╗
# ██╔══██╗██╔════╝╚══██╔══╝██╔══██╗██╔════╝██╔════╝
# ██████╔╝███████╗ ██║ ██████╔╝█████╗ █████╗
# ██╔═══╝ ╚════██║ ██║ ██╔══██╗██╔══╝ ██╔══╝
# ██║ ███████║ ██║ ██║ ██║███████╗███████╗
# ╚═╝ ╚══════╝ ╚═╝ ╚═╝ ╚═╝╚══════╝╚══════╝
pstree -a
# "Tell me about your relationship with your parents."
pstree -p
# This will also show you a process tree, but is more terse in the information it provides
#Display full tree information of a single process
pstree -plants $(pidof -s firefox)
pstree -plants $(pidof -s firefox)
# Display full tree information of a single process
#==============================##==============================#
# CMD PSTREE
#==============================##==============================#
Cheatsheets are an excellent complement to other information sources like Linux man-pages, Linux help, or How-To’s and tutorials, as they provide compact and easily accessible information. While man-pages and detailed tutorials often contain comprehensive explanations and extensive guides, cheatsheets summarize the most important options forthe command pstree in a clear format. This allows users to quickly access the needed information for pstree without having to sift through lengthy texts. Especially in stressful situations or for recurring tasks, cheatsheets for pstree are a valuable resource to work efficiently and purposefully.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
█║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌
██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗███████╗██████╗
████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
╚██╔═██╔╝██║ ██║██║ ██║ ╚███╔╝ █████╗ ██║ ██║
████████╗██║ ██║██║ ██║ ██╔██╗ ██╔══╝ ██║ ██║
╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═════╝
█║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
3.10 - 🖥️top
➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the top command with important options and switches using examples.
▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁
# ████████╗ ██████╗ ██████╗
# ╚══██╔══╝██╔═══██╗██╔══██╗
# ██║ ██║ ██║██████╔╝
# ██║ ██║ ██║██╔═══╝
# ██║ ╚██████╔╝██║
# ╚═╝ ╚═════╝ ╚═╝
# Update every <interval> samples:
top -i <interval>
# Set the delay between updates to <delay> seconds:
top -s <delay>
# Set event counting to accumulative mode:
top -a
# Set event counting to delta mode:
top -d
# Set event counting to absolute mode:
top -e
# Do not calculate statistics on shared libraries, also known as frameworks:
top -F
# Calculate statistics on shared libraries, also known as frameworks (default):
top -f
# Print command line usage information and exit:
top -h
# Order the display by sorting on <key> in descending order
top -o <key>
# Cool trick to color rows of `top` ouput with awk :)
top -bn 1 | awk '{ if ($1 == "PID") print "\033[41m"$0"\033[0m"; else if ($1 ~ "[0-9]+" && NR%2 == 0) print "\033[36m"$0"\033[0m"; else print }'
top -bn 1 | sed -n '/yes/p'
#==============================##==============================#
# CMD TOP #
#==============================##==============================#
Cheatsheets are an excellent complement to other information sources like Linux man-pages, Linux help, or How-To’s and tutorials, as they provide compact and easily accessible information. While man-pages and detailed tutorials often contain comprehensive explanations and extensive guides, cheatsheets summarize the most important options forthe command top in a clear format. This allows users to quickly access the needed information for top without having to sift through lengthy texts. Especially in stressful situations or for recurring tasks, cheatsheets for top are a valuable resource to work efficiently and purposefully.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
█║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌
██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗███████╗██████╗
████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
╚██╔═██╔╝██║ ██║██║ ██║ ╚███╔╝ █████╗ ██║ ██║
████████╗██║ ██║██║ ██║ ██╔██╗ ██╔══╝ ██║ ██║
╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═════╝
█║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
3.11 - 🖥️uptime
➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the uptime command with important options and switches using examples.
▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁
# ██╗ ██╗██████╗ ████████╗██╗███╗ ███╗███████╗
# ██║ ██║██╔══██╗╚══██╔══╝██║████╗ ████║██╔════╝
# ██║ ██║██████╔╝ ██║ ██║██╔████╔██║█████╗
# ██║ ██║██╔═══╝ ██║ ██║██║╚██╔╝██║██╔══╝
# ╚██████╔╝██║ ██║ ██║██║ ╚═╝ ██║███████╗
# ╚═════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝
# The uptime command tells how long the system has been running.
uptime
15:59:59 up 6:20, 4 users, load average: 0.81, 0.92, 0.82
#==============================##==============================#
# CMD UPTIME #
#==============================##==============================#
Cheatsheets are an excellent complement to other information sources like Linux man-pages, Linux help, or How-To’s and tutorials, as they provide compact and easily accessible information. While man-pages and detailed tutorials often contain comprehensive explanations and extensive guides, cheatsheets summarize the most important options forthe command uptime in a clear format. This allows users to quickly access the needed information for uptime without having to sift through lengthy texts. Especially in stressful situations or for recurring tasks, cheatsheets for uptime are a valuable resource to work efficiently and purposefully.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
█║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌
██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗███████╗██████╗
████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
╚██╔═██╔╝██║ ██║██║ ██║ ╚███╔╝ █████╗ ██║ ██║
████████╗██║ ██║██║ ██║ ██╔██╗ ██╔══╝ ██║ ██║
╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═════╝
█║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
4 - System Information
▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁
System information tools provide detailed information about the hardware and software configuration of a computer system. They help administrators understand the system’s capabilities, identify potential issues, and plan for upgrades or maintenance. Accurate system information is crucial for effective system management. These tools also assist in inventory management and compliance reporting.
4.1 - 🖥️df
➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the df command with important options and switches using examples.
▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁
# ██████╗ ███████╗
# ██╔══██╗██╔════╝
# ██║ ██║█████╗
# ██║ ██║██╔══╝
# ██████╔╝██║
# ╚═════╝ ╚═╝
# Printout disk free space in a human readable format
df -h
# Disk free space for ext2 file systems
df -t ext2
# Disk free space for file systems except ext2
df -x ext2
# Show inode usage. On Linux and others, display the inodes used per filesystem. Useful for determining how long it takes to backup or search the fs.
df -i
# Show information about a distinct file system /path
df /path
#==============================#
# CMD DF
#==============================##==============================#
df -hi
# Quickly find out how much data space is left on the partition that the current directory you are in resides.
df -h .
df -k | grep "/dev/hd\|/dev/sd\|\>awk '{print $1, $4/2^10}'"
# If your Linux device names are long enough that it wraps lines, try using -hP and pipe to column for nicer output.
df -hP | column -t
# Sort the output of df while keeping the header at the top.
df -hP | awk 'NR==1;NR>1{print|"sort -k5rn"}'
# Show the total space used on all your local disk partitions.
df -lP |awk '{sum += $3} END {printf "%d GiB\n", sum/2**20}'
# Annoyed by wrapped lines in df output. Try -P to unwrap the lines and piping to column will align the columns.
df -P | column -t
# Print disk space used on all ext3 or 4 FS in GiB.
df -Pl -t ext3 -t ext4 | tail -n+2 | awk '{ sum+=$3 } END { print sum/2**20 }'
# How do you find out the file system capacity or free space?
df -h
Filesystem Size Used Avail Use% Mounted on
/dev/dev1 97G 6.0G 86G 7% /
/dev/dev2 97G 96G 1G 99% /home
# The df command lists all the filesystems in the system. Infact, df -h gives more readable output - The used column tells the used space, and the available column tells the available space. This indicates /home is 99% full. The "-h" is to give the output in readable format such as kb,MB or GB.
df -text{2..4} -hP |column -t |tail -n+2 |sort -k5nr -k4n
# Show ext2, 3 & 4 FS w/ human readable output. Sort percent,space left.
# Show used disk space:
df -klP -t xfs -t ext2 -t ext3 -t ext4 -t reiserfs | grep -oE ' [0-9]{1,}( +[0-9]{1,})+' | awk '{sum_used += $2} END {printf "%.0f GB\n", sum_used/1024/1024}'
# Show allocated disk space:
df -klP -t xfs -t ext2 -t ext3 -t ext4 -t reiserfs | grep -oE ' [0-9]{1,}( +[0-9]{1,})+' | awk '{sum_used += $1} END {printf "%.0f GB\n", sum_used/1024/1024}'
# Get the available space on a partition as a single numeric value
df /path/to/dir | sed -ne 2p | awk '{print $4}'
# Explanation:
# sed -ne 2p prints the 2nd line
# awk '{print $4}' prints the 4th column
# Limitations: The output of the df command might be different depending on the system, and the available space might not be the 4th column. Make the necessary adjustments depending on your system.
#==============================##==============================#
# CMD df #
#==============================##==============================#
Cheatsheets are an excellent complement to other information sources like Linux man-pages, Linux help, or How-To’s and tutorials, as they provide compact and easily accessible information. While man-pages and detailed tutorials often contain comprehensive explanations and extensive guides, cheatsheets summarize the most important options forthe command df in a clear format. This allows users to quickly access the needed information for df without having to sift through lengthy texts. Especially in stressful situations or for recurring tasks, cheatsheets for df are a valuable resource to work efficiently and purposefully.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
█║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌
██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗███████╗██████╗
████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
╚██╔═██╔╝██║ ██║██║ ██║ ╚███╔╝ █████╗ ██║ ██║
████████╗██║ ██║██║ ██║ ██╔██╗ ██╔══╝ ██║ ██║
╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═════╝
█║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
4.2 - 🖥️dmidecode
➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the dmidecode command with important options and switches using examples.
▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁
# ██████╗ ███╗ ███╗██╗██████╗ ███████╗ ██████╗ ██████╗ ██████╗ ███████╗
# ██╔══██╗████╗ ████║██║██╔══██╗██╔════╝██╔════╝██╔═══██╗██╔══██╗██╔════╝
# ██║ ██║██╔████╔██║██║██║ ██║█████╗ ██║ ██║ ██║██║ ██║█████╗
# ██║ ██║██║╚██╔╝██║██║██║ ██║██╔══╝ ██║ ██║ ██║██║ ██║██╔══╝
# ██████╔╝██║ ╚═╝ ██║██║██████╔╝███████╗╚██████╗╚██████╔╝██████╔╝███████╗
# ╚═════╝ ╚═╝ ╚═╝╚═╝╚═════╝ ╚══════╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚══════╝
Dmidecode
The dmidecode command prints a system's DMI (aka SMBIOS) table contents in a human-readable format.
$ sudo dmidecode
# dmidecode 2.12
SMBIOS 2.6 present.
50 structures occupying 2056 bytes.
Table at 0x000FCCA0.
Handle 0x0000, DMI type 0, 24 bytes
BIOS Information
Vendor: American Megatrends Inc.
Version: 080015
Release Date: 08/22/2011
...
...
...
dmidecode | grep -A4 "Base B"
# Show your motherboard info in Linux. Thx @cargabsj175
#==============================##==============================#
# CMD dmidecode #
#==============================##==============================#
Cheatsheets are an excellent complement to other information sources like Linux man-pages, Linux help, or How-To’s and tutorials, as they provide compact and easily accessible information. While man-pages and detailed tutorials often contain comprehensive explanations and extensive guides, cheatsheets summarize the most important options forthe command dmidecode in a clear format. This allows users to quickly access the needed information for dmidecode without having to sift through lengthy texts. Especially in stressful situations or for recurring tasks, cheatsheets for dmidecode are a valuable resource to work efficiently and purposefully.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
█║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌
██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗███████╗██████╗
████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
╚██╔═██╔╝██║ ██║██║ ██║ ╚███╔╝ █████╗ ██║ ██║
████████╗██║ ██║██║ ██║ ██╔██╗ ██╔══╝ ██║ ██║
╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═════╝
█║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
4.3 - 🖥️du
➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the du command with important options and switches using examples.
▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁
# ██████╗ ██╗ ██╗
# ██╔══██╗██║ ██║
# ██║ ██║██║ ██║
# ██║ ██║██║ ██║
# ██████╔╝╚██████╔╝
# ╚═════╝ ╚═════╝
# To sort directories/files by size
du -sk *| sort -rn
# To show cumulative humanreadable size
du -sh
#==============================#
# CMD DU - Discusage
#==============================##==============================#
# Howto get directory size in Linux
#########################################
du -sch /tmp/test/
du -ch /tmp
# We will be using disk usage command ‘du’ and below of its options :
-s : Display only summary of each element
-h : Human readable format for size i.e. KB, MB, GB
-c : Produce grand total i.e. display total size
# Did you know most GNU programs can have their long options abbreviated? Ex: 'du --ap' same as 'du --apparent-size'. Must be unambiguous.
du -ma | sort -nr | head -n 20
# List the 20 largest files or folders under the current working directory.
du -sm $(find /start/dir/* -type d -maxdepth 1 -xdev) | sort -g
# Directories and its size - which directories and trees take up all the diskspace?
du -ha /var | sort -n -r | head -n 10
# If you want more human readable output try:
du -h –max-depth=1 Command
# The below command outputs the size of sub-folders within the current directory, in human readable format.
du -ch –max-depth=1 * | sort -rh
#
du -h
# To show all directories size including sub directories, type
du -sh
# To calculate the current directory size you are in (-s stand for summary)
du -sh *
# To show all the 1 level sub directories size (which you are not interested at sub sub directories.)
du -sh /home
# To show the size of specific directory
du -sh /home/*
# To show the size of all sub directories of a specific directory
du --ap
# Did you know most GNU programs can have their long options abbreviated? Long: du --apparent-size
du -sh */
#Space usage of directories only (This was the very first CLIMagic command posted on December 15th, 2009)
du -ma | sort -nr | head -n 20
# List the 20 largest files or folders under the current working directory.
du -sh */ | sort -h
# Show directory size and sort by human readable amount (MB, GB, etc.). Requires GNU sort for -h option.
du -h . | grep "^[0-9\.]\+G"
## Find out which of your directories(below the current directory) occupy at least 1GB of space.
du -cms .[^.]*/ */ | sort -rn | head
# Show the 10 largest directories at top level along with total usage. All in megabytes.
# Get an ordered list of subdirectory sizes This piece of code lists the size of every file and subdirectory of the current directory, much like du -sch ./* except the output is sorted by size, with larger files and directories at the end of the list. Useful to find where all that space goes.
du -sk ./* | sort -n | awk 'BEGIN{ pref[1]="K"; pref[2]="M"; pref[3]="G";} { total = total + $1; x = $1; y = 1; while( x > 1024 ) { x = (x + 1023)/1024; y++; } printf("%g%s\t%s\n",int(x*10)/10,pref[y],$2); } END { y = 1; while( total > 1024 ) { total = (total + 1023)/1024; y++; } printf("Total: %g%s\n",int(total*10)/10,pref[y]); }'
du -sch /tmp/test/
# Howto get directory size in Linux
du -ch /tmp
# We will be using disk usage command ‘du’ and below of its options :
# -s : Display only summary of each element
# -h : Human readable format for size i.e. KB, MB, GB
# -c : Produce grand total i.e. display total size
du -ak afile shows file size in KB
# The above command will list files with their size in mb. Now you can apply logic to add the first column values to get total size using awk.
du -am afile shows file size in MB.
# likewise du -ag afile shows file size in GB.
du -s /tmp/* | sort -n
#
du -a /var | sort -n -r | head -n 10
#
## How to find out which user consumes the maximum space?
du -s * | sort -nr | head -5
1959288 user3
906328 user2
726000 user1
560800 user4
# In my case, all the users home directory are under /home. So, I get into the /home directory, and fire the below command:
# du command gives the disk usage in kilo bytes.. When du is run on any given directory, it gives the disk usage of each and every file present in the directory and their sub-directories. The "-s" option in du gives only the usage in summary for a directory which is what ideally we need in this case. We need the summary of every directory's usage under /home and hence "*". sorting the output gives the top disk users in the beginning of the output. And 'head -5' gives us the top 5 users.
du -sh *
4.1G user3
2.1G user1
100M user2
# In order to get the disk usage in more understandable format, use - The '-h' option gives the output in the form of KB, MB and GB.
du
# Subdirectory sizes
du -h
# Show sizes of subdirectories
du -h --max-depth=1
# Subdirectory sizes - Make the sizes more humanly readable - Display the sizes of just one level of subdirectories
du -h --summarize *
# Subdirectory sizes - Make the sizes more humanly readable - Summarize the elements of this directory, humanly
du --max-depth=1 -h | sort -hr
# Linux Sort Folders By Size
du -hsx * | sort -rh | head -6
# Explanation of commands and switches.
# du – Estimate file space usages
# -hsx – (-h) Human Readable Format, (-s) Summaries Output, (-x) One File Format, skip directories on other file format.
# sort – Sort text file lines
# -rh – (-r) Reverse the result of comparison, (-h) for compare human readable format.
# head – output first n lines of file.
du -a /var/spool/ | sort -n -r | head -n 10
# find out top largest Files and Directories.
du -hsx * | sort -rh | head -10
# OR, If you want output in human readable format follow the below command.
# du -h : Display sizes in human readable format.
# du -s : Show total for each argument.
# du -x : Skip directoried on different file system.
# sort -r : Reverse the result of comparisons.
# sort -h : Compare human readable numbers.
# head -10 : Display the first 10 lines.
# head -n10 : Display the first 10 lines.
du -h -d 2 ~ | awk '$1 ~ /G/'
# -- show folders 2 levels deep over 1GB in the current user's home folder.
du -sh */ | sort -h
# Show directory size and sort by human readable amount (MB, GB, etc.). Requires GNU sort for -h option.
du -sh [a-m]*/ --exclude=export/
# Measure the disk space used by directories starting with a-m, skip exports dir. #GNU version FIXED
du -sh -I export [a-m]*
# Measure the disk space used by directories AND FILES starting with a-m, skip export dir. #BSD version
du -shc *.png | tail -1
# Display the total size used by PNG image files in the current directory
du --max-depth\=1 ~ | sort -n | tail -n10
# Bash onlinner of the day: list the 10 biggest folders under your home $
du --max-depth=1 -x -k | sort -n | awk 'function human(x) { s="KMGTEPYZ"; while (x>=1000 && length(s)>1) {x/=1024; s=substr(s,2)} return int(x+0.5) substr(s,1,1)"iB" } {gsub(/^[0-9]+/, human($1)); print}'
# List sub dir, sort by size, the biggest at the end, with human presentation i'm using -x : -x, --one-file-system skip directories on different file systems so mounts points aren't walked trough
# Linux Sort Folders By Size
du --max-depth=1 -h | sort -hr
# This piece of code lists the size of every file and subdirectory of the current directory, much like du -sch ./* except the output is sorted by size, with larger files and directories at the end of the list. Useful to find where all that space goes.
du -sk ./* | sort -n | awk 'BEGIN{ pref[1]="K"; pref[2]="M"; pref[3]="G";} { total = total + $1; x = $1; y = 1; while( x > 1024 ) { x = (x + 1023)/1024; y++; } printf("%g%s\t%s\n",int(x*10) y = 1; while( total > 1024 ) { total = (total + 1023)/1024; y++; } printf("Total: %g%s\n",int(total*10)/10,pref[y]); }'
du -ma | sort -nr | head -n 20
# List the 20 largest files or folders under the current working directory.
du -cms .[^.]*/ */ | sort -rn | head
# Show the 10 largest directories at top level along with total usage. All in megabytes. Thx @listrophy
du -sh */ | sort -h
# Show directory size and sort by human readable amount (MB, GB, etc.). Requires fairly recent version of GNU sort.
find / -size +100M -exec du -h {} \;
# find all files larger than 100MB and display their human readable size.
# Calculate the total disk space used by a list of files or directories
du -s file1 dir1 | awk '{sum += $1} END {print sum}'
# Explanation:
# This is really simple, the first column is the size of the file or the directory, which we sum up with awk and print the sum at the end.
# Use du -sk to count in kilobytes, du -sm to count in megabytes (not available in some systems)
## Alternative one-liners: Calculate the total disk space used by a list of files or directories
du -c
# Explanation: -c option of du prints the total size of the arguments
# Calculate the total disk space used by a list of files or directories
du -cshx ./a ./b
# Explanation:
# -s, --summarize; display only a total for each argument
# -c, --total; produce a grand total
# -x, --one-file-system; skip directories on different file systems
# -h, --human-readable; print sizes in human readable format (e.g., 1K 234M 2G)
# Calculate the total disk space used by a list of files or directories
du -cshx ./a ./b
# Explanation:
# -s, --summarize; display only a total for each argument
# -c, --total; produce a grand total
# -x, --one-file-system; skip directories on different file systems
# -h, --human-readable; print sizes in human readable format (e.g., 1K 234M 2G)
## Related one-liners
# Calculate the total disk space used by a list of files or directories
du -s file1 dir1 | awk '{sum += $1} END {print sum}'
# Explanation:
# This is really simple, the first column is the size of the file or the directory, which we sum up with awk and print the sum at the end.
# Use du -sk to count in kilobytes, du -sm to count in megabytes (not available in some systems)
# Sort du output in Human-readable format
du -hsx * | sort -rh
# Explanation: sort supports -h for human readable number sorting.
# Limitations: Probably a newer GNU only option for sort. :D
find / -maxdepth 1 -mindepth 1 -type d \! -empty \! -exec mountpoint -q {} \; -exec du -xsh {} + | sort -h
# Shows space used by each directory of the root filesystem excluding mountpoints/external filesystems (and sort the output) Excludes other mountpoints with acavagni's "mountpoint" idea, but with -exec instead of piping to an xargs subshell. Then, calling "du" only once with -exec's "+" option. The first "\! -exec" acts as a test so only those who match are passed to the second "-exec" for du. Show Sample Output:
find / -maxdepth 1 -mindepth 1 -type d -exec du -skx {} \; | sort -n
# Shows space used by each directory of the root filesystem excluding mountpoints/external filesystems (and sort the output)
# [root@docker ~]# grep -vE '^\s*(#|$)' /etc/nsswitch.conf
# passwd: files sss
# shadow: files sss
# group: files sss
# hosts: files dns myhostname
# bootparams: nisplus [NOTFOUND=return] files
# ethers: files
# netmasks: files
# networks: files
# protocols: files
# rpc: files
# services: files sss
# netgroup: nisplus sss
# publickey: nisplus
# automount: files nisplus sss
# aliases: files nisplus
find / -maxdepth 1 -type d | xargs -I {} sh -c "mountpoint -q {} || du -sk {}" | sort -n
# Shows space used by each directory of the root filesystem excluding mountpoints/external filesystems (and sort the output) Useful to see at glance which directory under the root file is using most space Show Sample Output:
# [root@server ~]# df -h
# Filesystem Size Used Avail Use% Mounted on
# /dev/mapper/vm-root 18G 7.8G 11G 44% /
# devtmpfs 1.3G 0 1.3G 0% /dev
# tmpfs 1.3G 0 1.3G 0% /dev/shm
# tmpfs 1.3G 9.5M 1.3G 1% /run
# tmpfs 1.3G 0 1.3G 0% /sys/fs/cgroup
# /dev/sda1 1014M 287M 728M 29% /boot
# [root@server ~]# find / -maxdepth 1 -type d | xargs -I {} sh -c "mountpoint -q {} || du -sk {}" | sort -n
# 0 /mnt
# 0 /srv
# 0 /vbox_share
# 212 /tmp
# 256 /root
# 48856 /etc
# 72692 /media
# 177668 /opt
# 933676 /home
# 2238568 /var
# 4586604 /usr
du -sh *
# List the size (in human readable form) of all sub folders from the current location -s summary -h human slightly different : will display side by side the sizes of individual files and of directories in current dir will not display total size of './'
du -h -d1
# List the size (in human readable form) of all sub folders from the current location Simple and easy to remember. -h is human, -d1 = depth 1. disk usage, human, depth 1 Show Sample Output:
du -h --max-depth=1 --one-file-system /
# du command without showing other mounted file systems
# Linux Sort Folders By Size
du --max-depth=1 -h | sort -hr
#==============================##==============================#
# CMD du #
#==============================##==============================#
Cheatsheets are an excellent complement to other information sources like Linux man-pages, Linux help, or How-To’s and tutorials, as they provide compact and easily accessible information. While man-pages and detailed tutorials often contain comprehensive explanations and extensive guides, cheatsheets summarize the most important options forthe command du in a clear format. This allows users to quickly access the needed information for du without having to sift through lengthy texts. Especially in stressful situations or for recurring tasks, cheatsheets for du are a valuable resource to work efficiently and purposefully.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
█║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌
██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗███████╗██████╗
████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
╚██╔═██╔╝██║ ██║██║ ██║ ╚███╔╝ █████╗ ██║ ██║
████████╗██║ ██║██║ ██║ ██╔██╗ ██╔══╝ ██║ ██║
╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═════╝
█║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
4.4 - 🖥️hdparm
➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the hdparm command with important options and switches using examples.
▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁
# ██╗ ██╗██████╗ ██████╗ █████╗ ██████╗ ███╗ ███╗
# ██║ ██║██╔══██╗██╔══██╗██╔══██╗██╔══██╗████╗ ████║
# ███████║██║ ██║██████╔╝███████║██████╔╝██╔████╔██║
# ██╔══██║██║ ██║██╔═══╝ ██╔══██║██╔══██╗██║╚██╔╝██║
# ██║ ██║██████╔╝██║ ██║ ██║██║ ██║██║ ╚═╝ ██║
# ╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝
# get information about hard disks
hdparm -I /dev/sda
# perform timings of device/cache reads for benchmark and comparison purposes
hdparm -tT /dev/sda
Cheatsheets are an excellent complement to other information sources like Linux man-pages, Linux help, or How-To’s and tutorials, as they provide compact and easily accessible information. While man-pages and detailed tutorials often contain comprehensive explanations and extensive guides, cheatsheets summarize the most important options forthe command hdparm in a clear format. This allows users to quickly access the needed information for hdparm without having to sift through lengthy texts. Especially in stressful situations or for recurring tasks, cheatsheets for hdparm are a valuable resource to work efficiently and purposefully.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
█║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌
██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗███████╗██████╗
████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
╚██╔═██╔╝██║ ██║██║ ██║ ╚███╔╝ █████╗ ██║ ██║
████████╗██║ ██║██║ ██║ ██╔██╗ ██╔══╝ ██║ ██║
╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═════╝
█║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
4.5 - 🖥️lsb_release
➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the lsb_release command with important options and switches using examples.
▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁
# ██╗ ███████╗██████╗ ██████╗ ███████╗██╗ ███████╗ █████╗ ███████╗███████╗
# ██║ ██╔════╝██╔══██╗ ██╔══██╗██╔════╝██║ ██╔════╝██╔══██╗██╔════╝██╔════╝
# ██║ ███████╗██████╔╝ ██████╔╝█████╗ ██║ █████╗ ███████║███████╗█████╗
# ██║ ╚════██║██╔══██╗ ██╔══██╗██╔══╝ ██║ ██╔══╝ ██╔══██║╚════██║██╔══╝
# ███████╗███████║██████╔╝███████╗██║ ██║███████╗███████╗███████╗██║ ██║███████║███████╗
# ╚══════╝╚══════╝╚═════╝ ╚══════╝╚═╝ ╚═╝╚══════╝╚══════╝╚══════╝╚═╝ ╚═╝╚══════╝╚══════╝
lsb_release -a
# The command ‘lsb_release‘ print distribution-specific information. If lsb_release is not installed, you can apt ‘lsb-core‘ on Debian or yum ‘redhat-lsb‘ on Red Hat the package.
lsb_release -a || cat /etc/redhat-release
# Show Linux distro release information or die trying.
#==============================##==============================#
# CMD LSB_RELEASE #
#==============================##==============================#
Cheatsheets are an excellent complement to other information sources like Linux man-pages, Linux help, or How-To’s and tutorials, as they provide compact and easily accessible information. While man-pages and detailed tutorials often contain comprehensive explanations and extensive guides, cheatsheets summarize the most important options forthe command lsb_release in a clear format. This allows users to quickly access the needed information for lsb_release without having to sift through lengthy texts. Especially in stressful situations or for recurring tasks, cheatsheets for lsb_release are a valuable resource to work efficiently and purposefully.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
█║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌
██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗███████╗██████╗
████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
╚██╔═██╔╝██║ ██║██║ ██║ ╚███╔╝ █████╗ ██║ ██║
████████╗██║ ██║██║ ██║ ██╔██╗ ██╔══╝ ██║ ██║
╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═════╝
█║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
4.6 - 🖥️lsblk
➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the lsblk command with important options and switches using examples.
▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁
# ██╗ ███████╗██████╗ ██╗ ██╗ ██╗
# ██║ ██╔════╝██╔══██╗██║ ██║ ██╔╝
# ██║ ███████╗██████╔╝██║ █████╔╝
# ██║ ╚════██║██╔══██╗██║ ██╔═██╗
# ███████╗███████║██████╔╝███████╗██║ ██╗
# ╚══════╝╚══════╝╚═════╝ ╚══════╝╚═╝ ╚═╝
# list block devices - Shows all block devices in a tree with descruptions of what they are.
lsblk -o name,type,fstype,label,partlabel,model,mountpoint,size
Cheatsheets are an excellent complement to other information sources like Linux man-pages, Linux help, or How-To’s and tutorials, as they provide compact and easily accessible information. While man-pages and detailed tutorials often contain comprehensive explanations and extensive guides, cheatsheets summarize the most important options forthe command lsblk in a clear format. This allows users to quickly access the needed information for lsblk without having to sift through lengthy texts. Especially in stressful situations or for recurring tasks, cheatsheets for lsblk are a valuable resource to work efficiently and purposefully.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
█║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌
██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗███████╗██████╗
████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
╚██╔═██╔╝██║ ██║██║ ██║ ╚███╔╝ █████╗ ██║ ██║
████████╗██║ ██║██║ ██║ ██╔██╗ ██╔══╝ ██║ ██║
╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═════╝
█║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
4.7 - 🖥️lscpu
➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the lscpu command with important options and switches using examples.
▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁
# ██╗ ███████╗ ██████╗██████╗ ██╗ ██╗
# ██║ ██╔════╝██╔════╝██╔══██╗██║ ██║
# ██║ ███████╗██║ ██████╔╝██║ ██║
# ██║ ╚════██║██║ ██╔═══╝ ██║ ██║
# ███████╗███████║╚██████╗██║ ╚██████╔╝
# ╚══════╝╚══════╝ ╚═════╝╚═╝ ╚═════╝
# The lscpu command displays in output system's CPU architecture information (such as number of CPUs, threads, cores, sockets, and more).
$ lscpu
Architecture: i686
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 1
On-line CPU(s) list: 0
Thread(s) per core: 1
Core(s) per socket: 1
Socket(s): 1
Vendor ID: AuthenticAMD
CPU family: 16
Model: 6
Stepping: 3
CPU MHz: 2800.234
BogoMIPS: 5600.46
Virtualization: AMD-V
L1d cache: 64K
L1i cache: 64K
L2 cache: 1024K
#==============================##==============================#
# CMD LSCPU #
#==============================##==============================#
Cheatsheets are an excellent complement to other information sources like Linux man-pages, Linux help, or How-To’s and tutorials, as they provide compact and easily accessible information. While man-pages and detailed tutorials often contain comprehensive explanations and extensive guides, cheatsheets summarize the most important options forthe command lscpu in a clear format. This allows users to quickly access the needed information for lscpu without having to sift through lengthy texts. Especially in stressful situations or for recurring tasks, cheatsheets for lscpu are a valuable resource to work efficiently and purposefully.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
█║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌
██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗███████╗██████╗
████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
╚██╔═██╔╝██║ ██║██║ ██║ ╚███╔╝ █████╗ ██║ ██║
████████╗██║ ██║██║ ██║ ██╔██╗ ██╔══╝ ██║ ██║
╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═════╝
█║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
4.8 - 🖥️lshw
➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the lshw command with important options and switches using examples.
▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁
# ██╗ ███████╗██╗ ██╗██╗ ██╗
# ██║ ██╔════╝██║ ██║██║ ██║
# ██║ ███████╗███████║██║ █╗ ██║
# ██║ ╚════██║██╔══██║██║███╗██║
# ███████╗███████║██║ ██║╚███╔███╔╝
# ╚══════╝╚══════╝╚═╝ ╚═╝ ╚══╝╚══╝
# Get hardware information on Linux
# The lshw command extracts and displays detailed information on the hardware configuration of the machine.
# Generate full information report about all detected hardware
lshw
# Display hardware information in short
lshw -short
# Display only memory information
lshw -short -class memory
# Display processor information
lshw -class processor
# Display the disk drives with the disk class
lshw -short -class disk
# Display information about the partitions and controllers also,
# specify the storage and volume class along with the disk class
lshw -short -class disk -class storage -class volume
# Network adapter information
lshw -class network
# Display the address details of pci, usb, scsi and ide devices
lshw -businfo
# Generate report in html format
lshw -html > hardware.html
# Generate report in xml format
lshw -html > hardware.html
$ sudo lshw
[sudo] password for himanshu:
himanshu-desktop
description: Desktop Computer
product: To Be Filled By O.E.M. (To Be Filled By O.E.M.)
vendor: To Be Filled By O.E.M.
version: To Be Filled By O.E.M.
serial: To Be Filled By O.E.M.
width: 32 bits
capabilities: smbios-2.6 dmi-2.6 smp-1.4 smp
...
...
..
#==============================##==============================#
# CMD LSHW #
#==============================##==============================#
Cheatsheets are an excellent complement to other information sources like Linux man-pages, Linux help, or How-To’s and tutorials, as they provide compact and easily accessible information. While man-pages and detailed tutorials often contain comprehensive explanations and extensive guides, cheatsheets summarize the most important options forthe command lshw in a clear format. This allows users to quickly access the needed information for lshw without having to sift through lengthy texts. Especially in stressful situations or for recurring tasks, cheatsheets for lshw are a valuable resource to work efficiently and purposefully.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
█║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌
██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗███████╗██████╗
████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
╚██╔═██╔╝██║ ██║██║ ██║ ╚███╔╝ █████╗ ██║ ██║
████████╗██║ ██║██║ ██║ ██╔██╗ ██╔══╝ ██║ ██║
╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═════╝
█║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
4.9 - 🖥️lspci
➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the lspci command with important options and switches using examples.
▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁
# ██╗ ███████╗██████╗ ██████╗██╗
# ██║ ██╔════╝██╔══██╗██╔════╝██║
# ██║ ███████╗██████╔╝██║ ██║
# ██║ ╚════██║██╔═══╝ ██║ ██║
# ███████╗███████║██║ ╚██████╗██║
# ╚══════╝╚══════╝╚═╝ ╚═════╝╚═╝
lspci | grep -q -e MEI -e HECI && echo "Check your firmware for Intel AMT vulnerability"
# Check physical host for vuln. CVE-2017-5689
#==============================##==============================#
# CMD LSPCI #
#==============================##==============================#
Cheatsheets are an excellent complement to other information sources like Linux man-pages, Linux help, or How-To’s and tutorials, as they provide compact and easily accessible information. While man-pages and detailed tutorials often contain comprehensive explanations and extensive guides, cheatsheets summarize the most important options forthe command lspci in a clear format. This allows users to quickly access the needed information for lspci without having to sift through lengthy texts. Especially in stressful situations or for recurring tasks, cheatsheets for lspci are a valuable resource to work efficiently and purposefully.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
█║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌
██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗███████╗██████╗
████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
╚██╔═██╔╝██║ ██║██║ ██║ ╚███╔╝ █████╗ ██║ ██║
████████╗██║ ██║██║ ██║ ██╔██╗ ██╔══╝ ██║ ██║
╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═════╝
█║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
4.10 - 🖥️smartctl
➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the smartctl command with important options and switches using examples.
▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁
# ███████╗███╗ ███╗ █████╗ ██████╗ ████████╗ ██████╗████████╗██╗
# ██╔════╝████╗ ████║██╔══██╗██╔══██╗╚══██╔══╝██╔════╝╚══██╔══╝██║
# ███████╗██╔████╔██║███████║██████╔╝ ██║ ██║ ██║ ██║
# ╚════██║██║╚██╔╝██║██╔══██║██╔══██╗ ██║ ██║ ██║ ██║
# ███████║██║ ╚═╝ ██║██║ ██║██║ ██║ ██║ ╚██████╗ ██║ ███████╗
# ╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚══════╝
# smartctl
# get SMART status information on your hard drives
# Quickly check the overall health of a drive
smartctl -H /dev/sda
# Obtain information on the drive: view the type of drive, its serial number, and so forth
smartctl -i /dev/sda
# initiate short tests for the drive
smartctl --test=short /dev/sda
# initiate long tests for the drive
smartctl --test=long /dev/sda
# abort the test
smartctl -X
Cheatsheets are an excellent complement to other information sources like Linux man-pages, Linux help, or How-To’s and tutorials, as they provide compact and easily accessible information. While man-pages and detailed tutorials often contain comprehensive explanations and extensive guides, cheatsheets summarize the most important options forthe command smartctl in a clear format. This allows users to quickly access the needed information for smartctl without having to sift through lengthy texts. Especially in stressful situations or for recurring tasks, cheatsheets for smartctl are a valuable resource to work efficiently and purposefully.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
█║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌
██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗███████╗██████╗
████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
╚██╔═██╔╝██║ ██║██║ ██║ ╚███╔╝ █████╗ ██║ ██║
████████╗██║ ██║██║ ██║ ██╔██╗ ██╔══╝ ██║ ██║
╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═════╝
█║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
5 - System Utilities
▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁