Linux runs on hardware as diverse as the Raspberry Pi and powerful supercomputers, making it a flexible choice of operating system. The command line interface provides much more control over the computer than the GUI. Many important tasks are easier, quicker, or only possible via commands.
G. Ostrov
Opening a Terminal
To open a terminal from the desktop, click on the Terminal icon in the applications menu or press CTRL+ ALT + T. A black screen will appear with a flashing command prompt.
sudo - Super User Do
Many Linux distributions don't give you admin privileges by default for core tasks like software installation. By prefacing any command with "sudo," you can get admin rights for that execution.
sudo apt upgrade
Navigating the Filesystem
pwd - Print working directory
This command shows the full path to the current directory, for example /home/user.
pwd
ls - List directory content
This command lists the contents of a directory.
ls
ls /var/log
ls -lha # show hidden files with details
ls *.py # show all Python files
cd - Change directory
Used to move around the filesystem.
cd Downloads
cd /var/log
cd - # go back to previous directory
cd ~ # go to home directory
Working with Files
cat - Print files to terminal
The cat command prints file contents to the terminal.
cat test.py
cat -n test.py # with line numbers
less - Print files to terminal in sections
The less command prints file contents in sections with scrolling capability.
less /var/log/syslog
grep - Search in files
Used to search for text within files.
lscpu | grep "MHz"
Editing Files with nano
Nano is the easiest command-line editor for beginners.
nano newfile.txt
nano test.py
To save press CTRL + O, to exit press CTRL + X.
System Resources & Management
htop - Display system processes
Shows current CPU load, RAM usage, and running system processes.
htop
free - Show amount of free and used RAM
free -m
dmesg - Monitor kernel events
sudo dmesg
File Management
mv - Move/rename files
mv test.py Documents/ # move file
mv test.py test2.py # rename file
rm - Delete files
rm test.py
cp - Copy files
cp test.py Documents/
cp -r test2/ Documents/ # copy directory
mkdir - Create directory
mkdir Work
Software Installation
apt - Install and manage software
sudo apt update
sudo apt install vlc
sudo apt upgrade -y
Network Connectivity & Internet
ping - Check connectivity
ping google.com
ping 8.8.8.8
hostname - Get IP address
hostname -I
curl - Transfer data over network
curl http://example.com/image.jpg -o image.jpg
Time Savers
history - Command history
history
!117 # run command number 117
history | grep "apt"
Useful keyboard shortcuts
- CTRL + R - interactive search through command history
- TAB - auto-completion for commands and paths
- Arrow keys up/down - navigate through command history
alias - Create command shortcuts
alias updater="sudo apt update && sudo apt upgrade -y"
Official Linux Foundation website: https://www.linuxfoundation.org/
If you encounter any problems, contact us - we'll help you quickly and professionally!