Search for:
  • Home/
  • Bash/
  • The Beginner’s guide to Linux Bash
Linux

The Beginner’s guide to Linux Bash

If you’re like me then you are new to the world of Linux. So lets enjoy the realm of open-source operating systems! Linux offers unparalleled flexibility and power, but for beginners, its command-line interface can seem like a daunting labyrinth. Fear not, for we’ve crafted a handy cheat sheet to help you navigate this exciting terrain with ease.

Visualise File Trees

Linux commands often involve directories and file paths. Visualise your file system like a tree. The root directory (“/”) is the trunk, and branches lead to subdirectories. To move up one level, use “cd ..,” where “..” signifies the parent directory. Visualising this tree structure can help you navigate effortlessly.

Aliases for Efficiency

Create custom aliases to shorten lengthy or frequently used commands. For instance, if you’re tired of typing “ls -la” to list all files, create an alias like “ll” that maps to the full command. Just remember to save aliases in your shell configuration file (e.g., “.bashrc”).

Mindful Mnemonics with Shell Scripts

Take mnemonics to the next level with shell scripts. Write simple scripts that use descriptive names to encapsulate complex commands. For example, if you often compress files, create a script named “compressmyfiles.sh” that contains the gzip or tar command, making it easy to recall.

Flashcards for Command Recognition

Create digital or physical flashcards with the command on one side and its description on the other. Quiz yourself during spare

moments. Repetition is the key to retention.

https://www.brainscape.com/packs/bash-2296517?origin=genome

https://www.cram.com/

Command Line Practice Games

There are fun command-line games and quizzes designed to help you learn Linux commands in an engaging way. One popular option is “Terminus,” a game that challenges your command-line skills in a game-like environment.Try the links below too

https://gitlab.com/slackermedia/bashcrawl

https://www.redhat.com/en/command-line-heroes/bash/index.html?extIdCarryOver=true&sc_cid=701f2000001OH7nAAG

Interactive Tutorials and Learning Platforms

Take advantage of interactive online tutorials and learning platforms tailored for Linux beginners. Websites like Codeademy and Linux Journey offer hands-on courses that teach you Linux commands in an interactive manner.

Cheat Sheets as Quick References

Cheat sheets are our best friends. Print out or bookmark cheat sheets that list essential Linux commands and their purposes. Having a quick reference at your fingertips can save time and reduce frustration. Rember to use whatis, man and apropos too!

CommandDescription
hostnamectlGet system information including the operating system, kernel, and release version.
dateDisplay the current system date and time.
hostnameDisplay the hostname of the system.
ifconfigDisplay the IP and MAC address of the system.
wDisplay currently logged-in users in the system.
free -mDisplay free and used memory in the system.
topDisplay all running processes.
lsList all files and directories in the current working directory.
ls -alList all files and directories, including hidden files, with additional information like permissions, size, and owner.
cdChange the directory to the home directory.
cd ..Change the directory to one level up.
cat filenameDisplay the content of the file.
cat file1 file2 > file3Combine two files named file1 and file2 and store the output in a new file, file3.
tail filenameDisplay the last 10 lines of a file.
head filenameDisplay the first 10 lines of a file.
mv oldfile newfileRename a file.
rm filenameDelete a file.
mkdir dirnameCreate a directory.
rm -rf dirnameRemove a directory.
historyPrint a history list of all commands.
clearClear the terminal.
shutdown -h nowShut down the system.
rebootRestart the system.
Networking CommandsDescription
ip addr showOr ifconfig – List all IP addresses and network interfaces.
ip addr add IP-Address dev eth1Add a temporary IP address to interface eth1.
netstat -pnltuDisplay all listening ports.
whois domainnameDisplay more information about any domain.
dig domainnameDisplay DNS information of any domain.
host domainnamePerform an IP lookup for a domain.
dig -x IP-AddressPerform a reverse lookup of an IP address.
dig -x domainnamePerform a reverse lookup on a domain.
ping host-ipCheck connectivity between two hosts.
File Permission CommandsDescription
ls -l filenameCheck the current permission of any file.
chmod 777 filenameAssign full (read, write, and execute) permission to everyone.
chmod -R 777 dirnameAssign full permission to the directory and all sub-directories.
chmod 766 filenameAssign full permission to the owner, and read and write permission to the group and others.
chmod -x filenameRemove the execution permission of any file.
chown username filenameChange the ownership of a file.
chown user:group filenameChange the owner and group ownership of a file.
chown -R user:group dirnameChange the owner and group ownership of the directory and all sub-directories.
User and Group Management CommandsDescription
wDisplay all login users.
useradd usernameAdd a new user account.
userdel -r usernameDelete a user account.
usermod [option] usernameChange the user account information, including group, home directory, shell, expiration date.
usermod -aG groupname usernameAdd a user to a specific group.
groupadd groupnameCreate a new group.
groupdel groupnameRemove a group.
lastDisplay information of the last login user.
idDisplay UID and GID of the current user.
Process Management CommandsDescription
psDisplay all active processes.
`ps -efgrep processname`
topManage and display all processes in real-time.
pstreeDisplay processes in a tree-like diagram.
lsofList all files opened by running processes.
kill pidKill a specific process using its process ID.
killall processnameKill all processes by name.
bgDisplay stopped or background jobs.
pidof processnameGet the PID of any process.
Disk Management CommandsDescription
fdisk -lList all disk partitions.
fdisk /dev/sdaCreate a new partition on the /dev/sda device.
mkfs.ext4 /dev/sda1Format the partition named /dev/sda1.
fsck.ext4 /dev/sda1Check and repair a filesystem for any errors.
mount /dev/sda1 /mntMount any partition to any directory.
df -hDisplay free space of mounted file systems.
df -iDisplay free inodes on the filesystem.
du -hsDisplay the size of your current directory.
lsblkDisplay information about block devices.
lsusb -tvDisplay all USB devices.
hdparm -tT /dev/sdaPerform a read speed test on disk /dev/sda.
badblocks -s /dev/sdaTest for unreadable blocks on disk /dev/sda.
Package Management CommandsDescription
apt-get install packagenameInstall the package on Debian-based distributions.
apt-get remove packagenameRemove a package on Debian-based distributions.
`dpkg -lgrep -i installed`
dpkg -i packagename.debInstall a .deb package.
apt-get updateUpdate the repository on Debian-based distributions.
apt-get upgrade packagenameUpgrade a specific package on Debian-based distributions.
apt-get autoremoveRemove all unwanted packages on Debian-based distributions.
yum install packagenameInstall the package on RPM-based distributions.
yum remove packagenameRemove a package on RPM-based distributions.
yum updateUpdate all system packages to the latest version on RPM-based distributions.
yum list --installedList all installed packages on RPM-based distributions.
yum list --availableList all available packages on RPM-based distributions.
Compress and Uncompress CommandsDescription
tar -cvf filename.tar filenameCompress a file in the Tar archive.
tar -xvf filename.tarUncompress a Tar file.
tar -tvf filename.tarList the content of the Tar file.
tar -xvf filename.tar file1.txtUntar a single file from a Tar file.
tar -rvf filename.tar file2.txtAdd a file to the Tar file.
zip filename.zip filenameCompress a single file to a zip.
zip filename.zip file1.txt file2.txt file3.txtCompress multiple files to a zip.
zip -u filename.zip file4.txtAdd a file to a zip file.
zip -d filename.zip file4.txtDelete a file from a zip file.
unzip -l filename.zipDisplay the content of a zip archive file.
unzip filename.zipUnzip a file.
unzip filename.zip -d /dirnameUnzip a file to a specific directory.

9. YouTube Tutorials and Video Guides

YouTube is a treasure trove of Linux tutorials and guides. Visual learners can watch experts demonstrate commands, making it easier to understand and remember.

10. Join Linux Communities

Join online Linux communities and forums like Stack Exchange or Reddit’s r/linux4noobs. Engaging in discussions and helping others solve problems is an excellent way to reinforce your understanding of Linux commands.

https://www.linux.org/forums/

https://forum.mxlinux.org/

https://forums.linuxmint.com/

https://bbs.archlinux.org/

Conclusion

Learning Linux commands may seem like a challenge at first, but with a combination of mnemonics, visualisations, custom aliases, and interactive resources, you can quickly become proficient. The journey to Linux mastery begins with a single command, and before you know it, you’ll be navigating the command-line interface with confidence and innovation.

So, roll up your sleeves, embrace the penguin-powered world of Linux, and let the command-line adventure begin!

Leave A Comment

All fields marked with an asterisk (*) are required