Access the Linux Basics Handbook here.
- Users in Linux
- Text Editors
- Basic File System
- Paths in Linux
- Terminal Shortcuts
- Basic Linux Commands
- Chmod Calculator
- Executing Software
- Process Manipulation
- Changing Hostname
- Changing Domain Name
- Configuring Apache Server
- Changing Apache Port
- Software Installation Without Apt
- Error Resolving in Linux Apt
- Running Multiple Commands in a Single Terminal
- Regular User: Home directory
- Root User: Full access [ADMIN] (the superuser of the system)
- Service User: Service access (for servers)
Note:
If a regular user gains root access, they can usesudobefore any command to utilize root privileges.
To get full root access, use thesudo sucommand.
Vim is a popular text editor in Linux. Common commands include:
- I: Enter insert mode
- esc: Exit insert mode
- :wq: Exit and save changes
- :q!: Exit without saving changes
- /bin: Basic programs (e.g.,
ls,cd,mv) - /sbin: System programs (e.g.,
fdisk,sysctl,mkfs) - /etc: Configuration files (default values)
- /temp: Temporary files
- /usr/bin: Applications (e.g.,
apt,nmap) - /usr/share: Application support and data files
- /home: Personal directories of users
- /root: Home directory of the superuser [ADMIN]
Below is an example of a directory structure:
Desktop
├── IntelliJ idea.desktop
├── Joshi
├── Kushal
│ ├── Birthday
│ └── Happy
│ └── hero.txt
├── Prasad
│ ├── Hello
│ └── Sir
├── firefox-esr.desktop
└── libreoffice-startcenter.desktop
Note:
gedit cd /Desktop/Kushal/Happy/hero.txtis an absolute path (accessible from anywhere).gedit hero.txtis a relative path (requires you to be in theHappydirectory, for example).
- Tab: Autocomplete names
- Double Tab: Open selection menu
- Ctrl + C: Abort the current process
- Ctrl + L: Clear the terminal (same as running
clear) - Ctrl + D: Exit the terminal (same as the
exitcommand) - Ctrl + Alt + D: Minimize all terminals/commands (toggle)
- Ctrl + U: Clear the current line
- Ctrl + Z: Suspend the current process to the background
- Ctrl + A: Move the cursor to the beginning of the line
- Ctrl + E: Move the cursor to the end of the line
- Shift + Ctrl + C: Copy text in the terminal
- Shift + Ctrl + V: Paste text in the terminal
- help: Shows basic commands and their uses.
- man: Displays the complete manual for a command or program.
- ls: Lists all files and folders in a directory.
ls -ashows hidden files and folders.ls -ldisplays permissions, dates, and user/group information.ls -Rlists directories recursively.
- cd: Change directory.
- pwd: Show the present working directory.
- clear: Clear the terminal screen.
- history: Displays the history of commands.
- echo / printf: Print text to the terminal.
- mkdir: Create a new directory.
Note:
- Prepend a filename with a dot (e.g.,
.Kushal) to make it hidden.- Use
cd ..to move up one directory.- To create a directory with spaces, use quotes (e.g.,
mkdir "Kushal Prasad Joshi") or escape the spaces (e.g.,mkdir Kushal\ Prasad\ Joshi).
- dir: Same as
ls. - mkdir: Create a directory.
- cp: Copy a file or folder.
- mv: Move a file or folder.
- rm: Remove (delete) a file or folder.
- Use
rm -r folderto remove directories recursively.
- Use
- sudo su root: Grant root privileges.
- cat: Display the contents of a file.
- nano: Command-line text editor.
- gedit: Graphical text editor.
- chmod: Change file or directory permissions.
- Example:
chmod +wxr filenameadds permissions, whilechmod -wxr filenameremoves them.
- Example:
Note:
In newer Linux versions, you can often usesudo suinstead ofsudo su root.
- Usage:
Changes file permissions based on the given numeric mode.
chmod filename ch-number
- Change Group:
Use thechgroupcommand as needed.
Note:
The format for permissions is typically Owner, Group, Public.
- ./filename: Execute a shell file.
- bash filename: Run a shell script.
- apt-get update: Update the packages list.
- apt-get upgrade: Upgrade all installed software.
- apt-get install software_name: Install specific software.
- apt-get update software_name: Update packages for a particular software.
- apt-get upgrade software_name: Upgrade a particular software.
Note:
apt-get updaterefreshes the package store.apt-get upgradeupdates all packages and tools.- In newer Linux distributions, the
aptcommand is often used in place ofapt-get.
- top: Displays processes consuming the most resources.
- ps: Shows the current processes.
ps -aincludes background processes.
- kill: Terminate a process manually.
- w: Shows who is logged on and what they are doing.
- whoami: Displays the current user's username.
- touch: Create an empty file.
Note:
- Use
kill PIDto terminate a process by its process ID (PID).Ctrl + Ccan stop an ongoing process in the terminal.
- Gain root access:
sudo su
- Navigate to the configuration directory:
cd /etc - Edit the hostname file:
gedit hostname
- Restart the system:
reboot
- Gain root access:
sudo su
- Navigate to the configuration directory:
cd /etc - Edit the hosts file:
gedit hosts
- Start the Apache server:
service apache2 start
- Access your domain by entering your IP address and port (e.g.,
Kushal:80) in a browser.
- Start the Apache server:
service apache2 start
- Navigate to the web directory:
cd /var/www/html/ - Edit the index page:
sudo gedit index.html
Note:
Useifconfigto find your IP address (e.g.,inet 192.168.78.141).
Apache typically runs on port 80 by default.
- Navigate to the configuration directory:
cd /etc/apache2 - Edit the ports configuration file:
Change the port number (e.g., from 80 to 8080).
gedit ports.conf
- Restart Apache:
service apache2 restart
- Verify by accessing your IP with the new port (e.g.,
192.168.78.141:8080).
- Navigate to the Downloads folder:
cd Downloads - Install the package:
dpkg -i filename
- Clone the repository:
git clone url
- Navigate to the folder:
cd folder - Execute the file:
./exefile
Note:
Always follow the installation instructions provided on GitHub for best results.
- Ensure you have root privileges by using
sudo su.
- Verify that you are connected to the internet.
- Navigate to the apt configuration directory:
cd /etc/apt - Edit the sources list:
Make sure that important lines are not commented out (lines starting with
gedit sources.list
#). - Update the package list:
apt update
apt-get install --fix-brokenrm -rf /var/lib/apt/list/*
apt-get update- The second command will run regardless of the success of the first command.
Example:cd ; ls
- The second command runs only if the first command is successful.
Example:cd && ls
- The second command runs only if the first command fails.
Example:cd || ls
This repository is licensed under the MIT License. You are free to use, modify, and distribute the code, provided that the original copyright notice and license text are included in all copies or substantial portions of the Software.
Go to Table of Contents.
