DEV Community

Cover image for Linux-Basics Commands & File Operations
Nivethithaa Saravanavel
Nivethithaa Saravanavel

Posted on

Linux-Basics Commands & File Operations

What is Linux?

  • Linux is an open-source operating system based on Unix, used to run computers, servers, and mobile devices.
  • It’s known for its stability, security, and flexibility, and powers systems like Android, servers, and supercomputers.

Installing Linux on Windows (WSL)

to install Linux in windows using WSL (Windows Subsystem for Linux):
This allows you to run Linux directly on Windows without a virtual machine.

wsl --install

Basic Linux Commands

Command Description
pwd Shows the present working directory
uname -a Displays system information
whoami Shows the current username
clear or Ctrl + L Clears the terminal screen
history Displays previously used commands
mkdir directory_name Creates a new directory
cd directory_name Changes to the specified directory

Working with the vi and nano Editors

File Editing Commands

Command Description
vi file_name.extension Create or open a file in vi editor
nano file_name Open file in nano editor
i Switch to insert mode in vi to add content
Esc + :wq Save changes and exit vi
Esc + :q! Exit vi without saving

Listing and Managing Files

Command Description
ls List all files and directories
sudo Execute commands as an admin
apt-get install package_name Install software in Ubuntu
Ctrl + Shift + C Copy text from terminal
Ctrl + Shift + V Paste text into terminal
touch file_name Create an empty file
rm * Remove all files in the current directory
rm *.txt Remove all .txt files in the directory
cat file_name Display file content
cp old_file new_file Copy a file
mv old_name new_name Rename or move a file
cat >> file_name Append content to a file
echo "text" >> file_name Directly append text to a file from terminal
history >> history.txt Save command history to a file

Top comments (1)

Collapse
 
m-a-h-b-u-b profile image
Md Mahbubur Rahman

Awesome start, Nivethithaa! Your Day 1 Linux guide makes learning the basics—like pwd, mkdir, ls, and editors like vi and nano—so approachable. Excited to follow along as you dive deeper into Linux!