Basics

Core Commands

# List files and directories
ls
ls /home
ls –al
ls –al /home/student

# Change current directory
cd /home

# Print current directory
pwd

# Copy files
cp a.txt /home
cp a.txt b.txt

# Move or rename file
mv a.txt /home
mv a.txt b.txt

# Remove empty directory
rmdir test

# Remove file or Non empty directory
rm a.txt
rm –r test

# Create directory
mkdir test

# Print file content
cat a.txt

# Search for text in file
grep "word" a.txt

# Display the first 10 lines of a file
head a.txt
head –n 5 a.txt

# Display the last 10 lines of a file
tail a.txt
tail –n 5 a.txt
tail –f a.txt

# Display text from file in one screen
less a.txt

# Display list of running processes
ps aux

# Display list of open files
lsof –i

# Display network connections
netstat –antp

# Display network information
ifconfig

# Sort content of a file
sort a.txt

# Remove duplicate lines (sort first)
uniq a.txt

# Display information about a file
stat a.txt

# Test network connectivity
ping google.com

# Display current user
whoami

# Change user passwd
passwd student

# Terminate process
kill 1845

# Search on files
find / -name a.txt
find / -name "*.txt"

# Text editor (Save: Ctrl+X)
nano filename

Special Characters

Redirection

Piping

Environment Variables

User Management

Important Files

/etc/passwd

/etc/shadow

/etc/group

SU

Sudo

Linux Boot Process

  • BIOS: Performs some system integrity checks then executes MBR.

  • MBR: It contains information about boot loader then loads and executes the boot loader (GRUB).

  • GRUB: displays a splash screen then executes kernel.

  • Kernel: mount partitions then executes init script.

  • Init: determine the Linux run level then executes runlevel programs.

  • Runlevel: responsible for which services started at which runlevel.

Linux Run Levels

Services

File System

  • /: Root directory, every thing starts from there.

  • /root: Root home directory, contains Desktop, Downloads, Documents and so on.

  • /bin: Contains users binaries (ls, cp, cat).

  • /sbin: Contains system binaries (reboot, ifconfig, fdisk).

  • /etc: Contains system configuration files.

  • /home: Home directory for all users (/home/student, /home/testuser).

  • /boot: Contains boot load files and kernel files.

  • /lib: Contains system libraries.

  • /var: Contains variable data which is continuously change in size (/var/log).

  • /usr: Contains user programs and it contains another bin (/usr/bin) & sbin (/usr/sbin)

    which contains second level user and system binaries.

  • /mnt: Mount directory where system admin can mount any partitions here.

  • /tmp: Temporary files (delete at reboot).

File Permissions

Installing Software

If the software don’t exist in the repository then you can go to the main website of the software and download the deb package.

Last updated