linux
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
linux [2021/01/16 14:14] – created roger | linux [2024/11/17 12:59] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 3: | Line 3: | ||
Useful Linux commands, with no particular order | Useful Linux commands, with no particular order | ||
- | ==== Check which program is using a particular port ==== | + | ===== Check which program is using a particular port ===== |
| | ||
<code bash> | <code bash> | ||
- | ==== Kill a particular PID ==== | + | ===== Kill a particular PID ===== |
<code bash> | <code bash> | ||
- | ==== Check the current folder size ==== | + | ===== Check the current folder size ===== |
<code bash>du -hs .</ | <code bash>du -hs .</ | ||
- | ==== Show filesystem information ==== | + | ===== Show filesystem information |
<code bash>df -h</ | <code bash>df -h</ | ||
+ | |||
+ | ===== SSH ===== | ||
+ | More info: https:// | ||
+ | |||
+ | ==== Copying local keys to a remote server ==== | ||
+ | |||
+ | <code bash> | ||
+ | |||
+ | ==== Create a remote tunnel into localhost ==== | ||
+ | |||
+ | <code bash>ssh -L local-port: | ||
+ | |||
+ | Note: '' | ||
+ | |||
+ | ==== Forward a local port to a remote host (like ngrok) ==== | ||
+ | |||
+ | <code bash>ssh -N -T -R local-port: | ||
+ | |||
+ | * -N Do not execute a remote command. | ||
+ | * -T Disable pseudo-terminal allocation. | ||
+ | * -R Specifies that connections to the given TCP port or Unix socket on the remote (server) host are to be forwarded to the local side. | ||
+ | |||
+ | ==== SCP ==== | ||
+ | |||
+ | <code bash>scp -r / | ||
+ | |||
+ | ===== tar & untar ===== | ||
+ | |||
+ | ==== tar ==== | ||
+ | |||
+ | <code bash>tar -czvf file.tar.gz file/ | ||
+ | |||
+ | * -c create | ||
+ | * -z gzip | ||
+ | * -v verbose | ||
+ | * -f filename | ||
+ | |||
+ | ==== untar ==== | ||
+ | |||
+ | <code bash>tar -xvf file.tar.gz</ | ||
+ | |||
+ | * -x extract | ||
+ | * -v verbose | ||
+ | * -f filename | ||
+ | |||
+ | ===== gpg encrypt/ | ||
+ | |||
+ | ==== Encrypt ==== | ||
+ | |||
+ | <code bash>gpg -c --cipher-algo AES256 file/ | ||
+ | |||
+ | You will be asked to enter a password | ||
+ | |||
+ | ==== Decrypt ==== | ||
+ | |||
+ | <code bash>gpg file/ | ||
+ | |||
+ | You will be asked to enter a password | ||
+ | |||
+ | ===== Download an entire website using wget ===== | ||
+ | |||
+ | More: https:// | ||
+ | |||
+ | <code bash> | ||
+ | wget \ | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | </ | ||
+ | |||
+ | ===== Create a X.509 sha256 self signed certificate ===== | ||
+ | |||
+ | <code bash> | ||
+ | openssl req \ | ||
+ | -x509 \ | ||
+ | -newkey rsa:4096 \ | ||
+ | -sha256 \ | ||
+ | -keyout mykeyname.key \ | ||
+ | -out mycertname.pem \ | ||
+ | -days 365 | ||
+ | -nodes # only if you need no password | ||
+ | </ | ||
+ | |||
+ | ===== Find ===== | ||
+ | |||
+ | ==== Find a specific file in the specified folder ==== | ||
+ | |||
+ | You can use: | ||
+ | |||
+ | <code bash> | ||
+ | find mypath -type f -name " | ||
+ | </ | ||
+ | |||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | ===== xargs ===== | ||
+ | |||
+ | '' | ||
+ | |||
+ | <code bash> | ||
+ | find . -type f -name \" | ||
+ | </ | ||
+ | |||
+ | What's happening? | ||
+ | |||
+ | * First, we are performing a [[linux# | ||
+ | <code bash> | ||
+ | ./ | ||
+ | ./ | ||
+ | </ | ||
+ | * Then, we pipe the output of the find command to '' | ||
+ | * '' | ||
+ | |||
+ | |||
+ | This command in particular is very usefull to check if all the JSON files in a repository are well formated in a CI/CD step. | ||
+ | |||
+ | ===== ncdu ===== | ||
+ | |||
+ | Ncdu is a disk usage analyzer with an ncurses interface. It is designed to find space hogs on a remote server where you don’t have an entire graphical setup available, but it is a useful tool even on regular desktop systems. Ncdu aims to be fast, simple and easy to use, and should be able to run in any minimal POSIX-like environment with ncurses installed. | ||
+ | |||
+ | Usage: | ||
+ | |||
+ | <code bash> | ||
+ | ncdu -x / | ||
+ | </ | ||
+ | |||
+ | Where ''/'' | ||
+ | |||
+ | ===== awk ===== | ||
+ | |||
+ | ==== Print the first column of a string ==== | ||
+ | |||
+ | <code bash> | ||
+ | echo "This is a string" | ||
+ | # Output: " | ||
+ | </ | ||
+ | |||
+ | ==== Print a full string in lowercase or uppercase ==== | ||
+ | |||
+ | <code bash> | ||
+ | echo "This Is A CaPiTaLiZeD String" | ||
+ | # Output: "this is a capitalized string" | ||
+ | |||
+ | echo "This Is A CaPiTaLiZeD String" | ||
+ | # Output: "THIS IS A CAPITALIZED STRING" | ||
+ | </ |
linux.1610806470.txt.gz · Last modified: 2024/11/17 12:59 (external edit)