# Linux Commands
### File and Directory Operations:
ls: List files and directories.
cd: Change directory.
pwd: Print working directory.
cp: Copy files or directories.
mv: Move or rename files or directories.
rm: Remove files or directories.
mkdir: Create a new directory.
### File Viewing and Editing:
cat: Concatenate and display the content of files.
more or less: Display content one screen at a time.
nano or vim or emacs: Text editors for file editing.
### System Information:
uname: Display system information.
df: Show disk space usage.
free: Display free and used memory.
### Process Management:
ps: Display information about processes.
top: Display dynamic real-time system statistics.
kill: Terminate processes.
killall: Kill processes by name.
### User and Group Management:
useradd: Add a new user.
userdel: Delete a user.
passwd: Change user password.
groupadd: Add a new group.
usermod: Modify user properties.
### Package Management:
pacman (Arch): Package management tool.
apt (Debian/Ubuntu): Package management tool.
nix-env (NixOS): Package management.
yum (RHEL/CentOS): Package management tool.
dnf (Fedora): Package management tool.
### Networking:
ifconfig or ip: Display and configure network interfaces.
ping: Test network connectivity.
nslookup or dig: DNS lookup.
netstat: Display network statistics.
### System Administration:
sudo: Execute commands with superuser privileges.
chmod: Change file permissions.
chown: Change file owner and group.
systemctl: Control the systemd system and service manager.
### Compression and Archiving:
tar: Create or extract tar archives.
gzip or gunzip: Compress or decompress files.
zip or unzip: Compress or decompress ZIP archives.
### Miscellaneous:
Verbose -v:
-v (verbose)
-vv (very verbose)
-vvv (Very Very Verbose):
echo: Display a message.
date: Display or set the system date and time.
history: Display command history.
grep: Search for patterns in files.
## KERNEL commands
- Another way to look at the ports/processes for sshd and containerd
```shell=
lsof -i :22
```
- Check network throughput to your system for 20 seconds
```shell=
ifstat 2 10
```
- Do a tcpdump to inspect the actual traffic into your system. Capture 1000 packets against your enp1s0 interface.
```shell=
tcpdump -ni enp1s0 -s0 -c 1000
```
**Check Sum** Verify the file you have at /root/motd
```shell=
cksum /root/motd
```
------
```shell=
lsmod
```
#### *lsmod* is a standard Linux command used to list the currently loaded kernel modules.
The information provided includes :
- module name
- size
- usage count
- dependencies
The example output demonstrates the typical format and content you would expect from running the lsmod command.
### Tracing :
```shell=
strace
```
- strace is a system call tracer. It captures and displays the system calls made by a process, along with their arguments and return values.
```shell=
ltrace
```
- Similar to strace, ltrace traces library calls made by a program, showing dynamic library calls.
```shell=
pstree
```
- pstree displays a tree diagram of processes, showing their relationships and parent-child connections.
```shell=
ps
```
- ps provides information about running processes. Variants like ps aux display detailed information about all running processes.
```shell=
top
```
- top provides a real-time, dynamic view of system processes, their resource usage, and other system metrics.
```shell=
htop
```
- Similar to top, htop is an interactive process viewer that provides a more user-friendly interface.
```shell=
tcpdump
```
- tcpdump is a packet analyzer that captures and displays network traffic on a system.
```shell=
trace # for Specific Process
ltrace # for Specific Process
```
- You can trace an already running process by attaching strace or ltrace to it. Replace PID with the process ID.
```shell=
dstat
```
- dstat is a versatile tool that provides real-time system resource statistics, including CPU, memory, disk, and network usage.