Linux

Core commands for effective Linux operation


What would be a simple procedure in Windows is a very different experience in Linux. Although capable of providing a desktop experience comparable to Windows/MacOS, it is primarily terminal based. Below are commands, functions, programs and procedures I often use to get the most of Linux's stable, flexible, and powerful operating systems.
  • Full update/upgrade
      Update and upgrade the software packages (Debian systems)
    • sudo apt update&&sudo apt upgrade -y

Programs
  • Curl
      Transfer data and run scripts with URLs
    • sudo apt install curl -y
      Run bash scripts with curl
    • curl -sSL https://massi.net/scripts/hello.sh > hello.sh && sudo bash ./hello.sh

  • OpenSSH
      Secure network communication and remote access.
    • sudo apt install openssh-client -y
    • sudo apt install openssh-server -y


Disk operations
  • Format drive
      ext4 is the default filesystem for Linux. Other filesystems could be mounted but would be limited in features. (permissions, performance, journaling, etc.)

      Identify drive (I.E: /dev/sdb)
    • sudo lsblk

    • Unmount drive
    • sudo umount /dev/sdb

    • Format drive to ext4 *erases drive*
    • sudo mkfs.ext4 /dev/sdb


  • Permanently mount drive with fstab

      Create the mount point
    • sudo mkdir /mnt/4TB
    • Identify drive (I.E: /dev/sdb)
    • sudo lsblk

    • Mount drive
    • sudo mount -t ext4 /dev/sdb /mnt/4TB
    • Get drive UUID and type
    • sudo lsblk -o NAME,FSTYPE,UUID,MOUNTPOINTS

    • Edit fstab
    • sudo nano /etc/fstab
    • fstab entries have the following format:
      [UUID] [mount-point] [type] [options] [dump] [pass]
      #4TB Disk
      UUID=b09bb4c8-de4d-4ce6-a93f-30c4c9241a58 /mnt/4TB ext4 defaults 0 0
      Test fstab
    • sudo findmnt --verify
    • *do not reboot if there are errors/warnings. An invalid fstab can render a disk unbootable*

  • Bind folders
      Attach the contents of one directory to another location in the file system.

      First location (I.E: /var/www/html) is the source, the original directory that you want to bind to another location. The second (I.E: /mnt/4TB/apache_html) is the target directory, the location where you want to bind the source directory.
    • sudo mount --bind /var/www/html /mnt/4TB/apache_html


    • Edit fstab
    • sudo nano /etc/fstab
    • The # line is a comment
      The format for a --bind entry is [source directory] [target directory] [none] [bind] [0 0]
      #sudo mount --bind /var/www/html /mnt/serveuse_ext4/serveuse_apache
      /var/www/html /mnt/serveuse_ext4/serveuse_apache none bind 0 0
      Test fstab
    • sudo findmnt --verify
    • *do not reboot if there are errors/warnings. An invalid fstab can render a disk unbootable*


For desktop experience
  • Nautilus-admin
      Facilitate navigation by allowing right clicking to elevate as admin
    • sudo apt install nautilus-admin -y

  • Create folder/file shortcut
      Navigate to folder where shortcut will be placed
    • cd /home/user/Desktop
    • Create link to file/folder
    • sudo ln -s /etc/file.txt

  • Xscreensaver
      Large collection of screensavers
    • sudo apt-get install xscreensaver xscreensaver-data-extra xscreensaver-gl-extra