Skip to main content
ID Academia
Linux
Beginner45 minLast updated: Topic 1 of 2

Linux Essentials — getting started with Linux

Meet Linux and Bash, manage files and permissions, check services and networking, and write your first script.

Not read

What you will learn here

  • Navigate, search and edit files in Bash
  • Permissions, sudo and apt packages
  • Check services and networking and write a first Bash script

Linux Essentials covers the terminal, files, permissions, packages, processes, services and networking. Based on the attached 28-slide presentation, with expanded explanations and commands for independent practice.

1. Unix, GNU, Linux and distributions

Unix is the historical foundation; GNU provides tools and free software; Linux is the kernel managing CPU, memory, disks, devices and networking. A distribution combines the kernel, system tools, packages and configuration into a usable system. Ubuntu is based on Debian; Fedora and RHEL belong to the Red Hat family. Drivers connect the kernel to hardware.

  • Commercial software is sold for payment and can also be open source. Freeware is free to use but not necessarily open source; shareware is a trial or limited version.
  • Open source provides source-code access under a license. FSF promotes user freedoms; OSI defines open-source principles. GPL requires preserving its license terms when distributing covered derivative works.
User → Terminal → Shell (Bash) → Programs → Linux kernel → Hardware
Linux distribution
├── Kernel + drivers
├── GNU and other system tools
├── Package manager (apt / dnf)
└── Configuration and applications
text

2. Terminal, shell and help

The terminal is the window; the shell interprets commands and launches programs. Bash is common; zsh and fish are alternatives. /etc/shells lists registered shells. Unlike CMD, Linux paths use / and names are case-sensitive: Notes.txt and notes.txt differ. uname -r shows the kernel version; /etc/os-release identifies the distribution.

uname -r
cat /etc/os-release
cat /etc/shells
whoami
id
ls --help
man ls
bash

3. Paths, files and directories

pwd shows the current directory; ls -la includes hidden files, owners and permissions; cd changes directories. A path starting with / is absolute; other paths are relative to the current directory. . means current, .. parent and ~ home. Quote names containing spaces.

mkdir -p ~/linux-practice/project/logs ~/linux-practice/backup
cd ~/linux-practice
pwd
ls -la
mkdir "My notes"
touch project/notes.txt
cp project/notes.txt project/notes-copy.txt
mv project/notes-copy.txt project/renamed.txt
cp -r project backup/
ls backup/project
rm -i project/renamed.txt
bash
  • mkdir -p creates parent directories. touch creates an empty file if absent, otherwise updates timestamps. cp copies; mv moves or renames.
  • If backup already exists, cp -r project backup/ creates backup/project. Repeating it may overwrite files, so inspect the destination first.
  • /home holds user homes; /etc configuration; /var/log logs; /tmp temporary files; /root the root user's home. A name starting with a dot is hidden from ordinary ls output.

4. Editing, searching and output redirection

nano notes.txt opens the editor if installed: Ctrl+O then Enter saves; Ctrl+X exits. Use cat for a short file and less for paged reading (q exits). grep searches text inside files; find searches for files by attributes. grep -i, -n, -r mean ignore case, show line numbers and search recursively.

cd ~/linux-practice
printf "INFO: started\nERROR: test\n" > project/logs/app.log
printf "INFO: finished\n" >> project/logs/app.log
cat project/logs/app.log
grep -in "error" project/logs/app.log
grep -rin "error" project/logs/
find . -type f -name "*.log"
head -n 5 project/logs/app.log
tail -n 5 project/logs/app.log
cat project/logs/app.log | grep "ERROR"
tail -f project/logs/app.log
bash
  • > replaces existing content; >> appends. | sends output to the next command. && runs the next command only if the previous one succeeded.
  • tail -f waits for new lines; stop it with Ctrl+C. The grep example should show 2:ERROR: test. Quoting *.log prevents the shell from expanding the pattern before find runs.

5. Users, permissions and sudo

ls -l shows type, permissions and owner. The three permission groups are owner, group and others: r=4 read, w=2 write, x=1 execute. On directories, x permits traversal; deleting a file depends on parent-directory permissions. chmod changes permissions; chown changes owner and group.

-rw-r-----  →  640
-   regular file (d = directory)
rw- owner: 4 + 2 = 6
r-- group: 4     = 4
--- others:     = 0

600 → private file
644 → owner reads/writes; others read
700 → private directory
755 → owner has full access; others read/execute
text
cd ~/linux-practice
touch project/private.txt
chmod 600 project/private.txt
ls -l project/private.txt
whoami
id
bash

6. Packages and processes

On Debian/Ubuntu, apt update refreshes package information, not installed programs. apt install installs; apt upgrade upgrades installed packages; apt remove removes them. Review proposed changes before confirming. ps aux lists processes and PIDs; top shows live resource use (q exits). kill PID sends SIGTERM for graceful termination; kill -9 sends SIGKILL as a last resort.

sudo apt update
sudo apt install tree
tree ~/linux-practice
ps aux
top
bash

7. Services, logs, networking and SSH

A service is a background program. systemctl status checks state; start starts it now; enable configures boot-time startup but does not necessarily start it immediately. journalctl reads systemd logs. The examples require an SSH server: Ubuntu/Debian use openssh-server and the ssh service; Fedora/RHEL usually use sshd.

systemctl status ssh
journalctl -u ssh -n 20 --no-pager
ip a
ip r
ping -c 4 8.8.8.8
getent hosts example.com
bash

ip a shows addresses and interfaces; ip r shows routes and the gateway. ping checks ICMP responses; no response does not prove a server is down. getent hosts checks name resolution using system settings, including /etc/hosts and DNS. For an authorized server, substitute the user and address in ssh user@server-ip; verify the service, port, credentials or key and server fingerprint.

  • No such file: check pwd, path and case. command not found: check spelling, installation and PATH.
  • Permission denied: check id and ls -l; for SSH also check user and authentication. Connection refused: check the listening service and port; a firewall may also reject the connection.

8. Independent practice — 15 minutes

In the practice VM, create a workspace, log, backup and private file. Run once; if you already followed the examples above, inspect files first to avoid overwriting important content.

mkdir -p ~/linux-practice
cd ~/linux-practice
mkdir -p project/logs backup
printf "INFO: started\nERROR: test\n" > project/logs/app.log
grep -in "error" project/logs/app.log
cp -r project backup/
find . -type f -name "*.log"
touch project/private.txt
chmod 600 project/private.txt
ls -l project/private.txt
bash
  • grep prints 2:ERROR: test; find locates the log and its backup copy.
  • ls -l shows -rw------- for private.txt. Your user owns it; the empty file has size 0.
  • Explain what changes if you replace >> with >, and why cp differs from mv. Test only on a disposable file.

9. Your first Bash script

In your practice directory, open nano hello.sh, enter the following text and save. The first line selects the interpreter; printf prints text and a newline.

#!/bin/bash
printf "Hello, Linux!\n"
bash

After saving, grant the owner execute permission and run it. ./ refers to the current directory; expected output is Hello, Linux!.

chmod u+x hello.sh
./hello.sh
bash

Check yourself

What does apt update do?

What do permissions 640 mean?

Which operator appends output without replacing content?

How do systemctl start and enable differ?

Was this page helpful?