Mr. Editor-in-chief Mr. Editor-in-chief May 22, 2025 Updated April 24, 2026

Linux Commands Use Cases

  1. zip & unzip. It works on Windows CMD, too
    tar -czvf 123.zip 1.sh 2.sh 3 # zip file 1.sh and file 2.sh and folder 3 into 123.zip
    mkdir 123 && mv 123.zip 123 # Create an empty directoy and move the .zip file into it
    tar -xzvf 123.zip # unzip 123.zip and extract all files and folders inside folder 123
  2. Check installed Linux kernels
    cat /etc/os-release
  3. Stop & start GUI
    sudo systemctl stop gdm
    sudo systemctl start gdm
  4. head and tail n number of lines (default is 10)
    head file -n 30
    tail file -n 5
  5. Open & close a command line prompt
    Ctrl + Alt + T
    exit
  6. About cp and mv, even scp or rsync
    cp /path/to/file /path/to/dir or cp -r /path/to/dir /path/to/another_dir These are but the basic commands to copy a file or a folder into another folder(directory). It's the same with mv, scp and rsync commands.
    In Windows, we know we can copy a file or a folder into another folder and then rename it. We can also do this in Linux but with just one step cp /path/to/file /path/to/dir/new_file_name or cp -r /path/to/dir /path/to/dir/new_dir_name. The same is also true with mv, scp and rsync commands.
  7. Find all processes that using a certain port and kill them all
    sudo netstat -tulnp | grep ':[PORT]'
    kill -9 [PID]
  8. Debug when the bluetooth can't be turned on
sudo apt install git dkms
git clone https://github.com/jeremyb31/bluetooth-6.8.git
sudo dkms add ./bluetooth-6.8
sudo dkms install btusb/4.2
reboot
sudo apt remove bluetooth
sudo apt install bluetooth
sudo systemctl enable bluetooth
sudo systemctl start bluetooth
reboot