Basic Linux Commands
Elizabeth Onyenekwe
Posted on March 27, 2022
Linux Shell Or Terminal
A shell is a program that receives commands from the user and gives it to the OS to process, and it shows the output. Linux's shell is its main part. Its distros come in GUI (graphical user interface), but basically, Linux has a CLI (command line interface). In this article, I am going to cover the basic commands that we use in the shell of Linux.
Basic Linux Commands
pwd: This command shows the current directory that you are in.
~$ pwd
ls: This command lists folders and files.
~$ ls
cd [dirname]: This command opens a folder on the system
~$ cd Documents
mkdir [dirname]: This command creates a folder.
~$ mkdir python-project
touch [filename]: This command creates a file.
~$ touch main.py
rm[filename]: This command deletes a file.
rm main.py
cd..: This command navigates up a directory.
cd..
rm -r [dirname]: This command deletes a folder
~$ rm -r python-project
cd /: This command takes the user to the root folder
cd /
clear: This command clears the terminal
~$ clear
cd [dirname]/[dirname]/[dirname]: This command lets you navigate down the directories to a particular folder.
~$ cd usr/local/bin
cd ../..: This command moves two hierarchies up the file system
cd ../..
cd ~: This command takes the user back to the home directory
cd ~
ls /[dirname]/[dirname]: This command lists all the files in the directory name after navigating to that particular directory.
ls /etc/network
mv[dirname][new-dirname]: This changes the folder name
mv web-application java-app
cp -r [dirname][new-dirname]: This copies the content of a particular folder into another folder.
cp -r java-app my-project
cp [filename][new-filename]: This copies the content of a file into another file.
cp readme.md readme-test.md
mv[filename][filename]: This changes the filename
mv readme.md readme-dev.md
ls -r [dirname]: This shows the entire content of that directory.
ls -r Documents
history: Gives a history of all past commands typed in the current terminal session
~$ history
ctrl + r: This key combination searches for the history of a command a user recently used.
ctrl + c: This key combination stops the current command that is running.
history[number]: This shows the last set of commands that were typed. The last set is determined by the number the user inputs.
history 20
ls -a: It shows all files including hidden files
ls -a
cat[filename]: This displays the file content
cat main.py
uname -a: This displays the system information and the kernel
~$ uname -a
cat /etc/os-release: This shows the version of your operating system
~$ cat /etc/os-release
lscpu: This shows the cpu information
~$ lscpu
lsmem: This displays the memory information
~$ lsmem
References
- Basic linux commands for beginners by Alok Naushad " https://maker.pro/linux/tutorial/basic-linux-commands-for-beginners "
- Techworld with Nana Devops Bootcamp
Posted on March 27, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.