Fading Coder

One Final Commit for the Last Sprint

Home > Tools > Content

GNU/Linux Fundamentals

Tools May 11 4
  • Console
    • Shell
    • Superuser root
    • CLI management tools
  • File Fundamentals
    • Directories
    • Links
    • Device files

Console

Shell

  • When you start a Linux system without a graphical interface, you are placed in a CLI

    • GUI (Graphical User Interface): interaction via visual windows, using mouse priamrily, keyboard secondarily
    • CLI (Command Line Interface): interaction via text windows, using keyboard only (no mouse)
    • TUI (Text User Interface): a middle ground between GUI and CLI, interaction via text windows using cursor positioning and a mouse
  • If you are in a GUI environment, press Ctrl+Alt+F3 to switch to a CLI console. Return to the GUI with Ctrl+Alt+F2

  • Initial CLI access often shows a text login prompt

    • You will see a prompt like hostname login:

    • Enter your username and press Enter. A Password: prompt will appear

    • Note that password input is invisible — usually achieved by setting the foreground and background colors to the same value

      • Foreground: the color of the text
      • Background: the color of the screen background
    • Usernames typically consist of lowercase letters

    • After a successful login, a welcome message and a command prompt appear. The welcome message is stored in /etc/motd

  • Getting a shell from the GUI

    • After boot, use the graphical login screen to enter your credentials
    • The Tab key can move between username and password fields, although using the mouse is usually more convenient
    • To obtain a shell in a GUI, launch a terminal emulator such as gnome-terminal, rxvt, or xterm
  • Closing a shell session

    • Press Ctrl+D
    • Run the exit command
  • Shutting down the Linux system

    • Single‑user mode: poweroff -i -f
    • Multi‑user mode: shutdown -h now
  • Basic shell concepts

Superuser root

  • The root account holds the highest privileges on a Linux system; it can do anything
  • Operations performed as root normally do not require additional verification (unless the system has been specially configured)
  • Therefore you must use root with extreme care and responsibility
  • If file permissions prevent a non‑root user from accessing or using a file, it is better to adjust the file permissions and group membership rather than resorting to the root account

CLI management tools

These are suggestions, especially for beginners:

  • mc (Midnight Commander): a visual character‑based file manager, useful for those transitioning from a GUI
  • vim, vim-tiny: powerful text editors. vim is almost a mandatory skill for CLI users, though it requires practice. vim-tiny is a lighter version
  • w3m: a text‑based web browser. Browsing the web in a CLI can be difficult, but w3m offers a gentler start. In the long run, you should use curl or wget instead
  • gpm: a copy‑paste utility for the text console, allowing mouse‑based cut and paste. Do not rely on it too much, or you may miss the real power of the CLI
  • sudo: a tool to grant limited root privileges to specific users. Warning: this is a very dangerous command. Many privilege escalation attacks succeed because of misconfigured sudo rules. Always follow official configuration guidelines strictly.

Installation method: apt-get install package-name. Installing software requires root privileges. Users with sudo rights can run sudo apt-get install package-name and will be prompted for their own password.

  • Although sudo is dangerous, it is used frequently. The fundamental principle is to grant the minimum necessary privileges for a user to perform their tasks

  • For a typical single‑user workstation (not running 24/7), a simple sudo configuration is sometimes acceptable — but only for a single‑user machine you manage. Never do this on a multi‑user workstation or a server

    # Add a user with full sudo privileges
    printf '%s\n' 'myuser ALL=(ALL) ALL' | sudo tee -a /etc/sudoers
    
    # Grant password‑less sudo
    printf '%s\n' 'myuser ALL=(ALL) NOPASSWD:ALL' | sudo tee -a /etc/sudoers
    
    # Consult 'man sudo' for more details
    
    
  • For access to restricted devices or files, consider using group memberships to provide limited access

File Fundamentals

  • In Linux, everything is a file

  • File names are usually composed of letters, digits, hyphens and underscores, and they are case‑sensitive

  • File types

    • Regular files – equivalent to ordinary files in Windows
    • Directories – similar to folders in Windows
    • Symbolic links – roughly analogous to Windows shortcuts
    • Character device nodes – device files that provide data streams (keyboards, serial ports, modems, etc.)
    • Block device nodes – device files that handle data storage (hard disks, floppy drives, CD‑ROM drives, flash drives, etc.)
    • Named pipes – used for inter‑process communication
    • Sockets – used for network communication between computers

Directories

  • Linux does not have the concept of drive letters (like C: or D:). Instead, the entire filesystem is a single tree starting at /

  • If you draw the filesystem, it looks like an upside‑down tree; therefore / is called the root directory

  • Every file or directory is identified by a fully qualified file name, also known as an absolute path

    • An absolute path starts with / (the root) and uses / to separate directory and file names
  • A path that uses the current directory as its reference point is called a relative path

    • Relative paths begin with . or ..
    • . stands for the current directory
    • .. stands for the parent (superior) directory
# Example: suppose our current location is /opt/application
# Directory structure: / -> opt -> application
# We are inside 'application'

/opt/application/config          # absolute path

./config                          # relative path, equivalent to /opt/application/config

..                                # relative path, equivalent to /opt

  • Common directories

Links

  • Hard links: additional names for an existing file
  • Symbolic links (soft links): special files that point to another file by name
  • Hard links can only be created for files on the same storage device. To link files across different devices, you must use symbolic links

Device files

  • Device files represent both physical devices and virtual devices; they are usually located in /dev/

  • There are two types of device files: character devices and block devices

  • Special device files

    • /dev/null: discards all data written to it; reading from it always returns end‑of‑file (EOF)
    • /dev/zero: provides an endless stream of null characters (\0), often used for initializing storage; data written to it is lost
    • /dev/random: returns a random byte from the true random number generator
    • /dev/urandom: returns a random byte from a cryptographically secure pseudo‑random number generator

Related Articles

Efficient Usage of HTTP Client in IntelliJ IDEA

IntelliJ IDEA incorporates a versatile HTTP client tool, enabling developres to interact with RESTful services and APIs effectively with in the editor. This functionality streamlines workflows, replac...

Installing CocoaPods on macOS Catalina (10.15) Using a User-Managed Ruby

System Ruby on macOS 10.15 frequently fails to build native gems required by CocoaPods (for example, ffi), leading to errors like: ERROR: Failed to build gem native extension checking for ffi.h... no...

Resolve PhpStorm "Interpreter is not specified or invalid" on WAMP (Windows)

Symptom PhpStorm displays: "Interpreter is not specified or invalid. Press ‘Fix’ to edit your project configuration." This occurs when the IDE cannot locate a valid PHP CLI executable or when the debu...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.