grep "pattern" filename.txtgrep -i "pattern" filename.txtgrep -r "pattern" /path/to/directorygrep -n "pattern" filename.txtsed 's/old/new/' filename.txtsed 's/old/new/g' filename.txtsed -i 's/old/new/g' filename.txtawk '{print $1}' filename.txtawk '/pattern/ {print}' filename.txtscp file.txt user@remote:/path/to/destination/scp -r folder/ user@remote:/path/ln original.txt hardlink.txtln -s original.txt symlink.txtsudo yum install zip # RHEL/CentOS
sudo apt install zip # Ubuntu/Debianzip archive.zip file.txtzip archive.zip file1.txt file2.txtzip -r archive.zip myfolder-r = recursive (include all files inside directory)
unzip archive.zipExtract to specific folder:
unzip archive.zip -d /path/to/directoryunzip -l archive.zipnohup= No Hang Up- Runs a command even after logout
- Useful for long-running jobs
nohup command &Example:
nohup python script.py &By default, output goes to:
nohup.out
nohup python script.py > output.log 2>&1 &Explanation:
>→ redirect output2>&1→ redirect errors&→ run in background
ps -ef | grep script.pyFind PID:
ps -ef | grep script.pyKill it:
kill PIDForce kill:
kill -9 PIDfind /path -option valuefind /home -name file.txtCase insensitive:
find /home -iname file.txt| Type | Command |
|---|---|
| File | -type f |
| Directory | -type d |
Example:
find /home -type f -name "*.txt"find /home -size +10M| Symbol | Meaning |
|---|---|
| + | Greater than |
| - | Less than |
Examples:
find / -size +100M
find / -size -1Gfind /home -perm 755find /home -user john