Table of contents
Introduction to Linux:
Linux is a free and open-source operating system kernel initially developed by Linus Torvalds in 1991.
It is widely used in various devices, from servers and desktop computers to smartphones and embedded systems.
Linux offers stability, security, and customization, making it a popular choice among tech enthusiasts, developers, and businesses.
Basic Linux Commands:
Check your present working directory:
Use the
pwd
command to know your current location in the terminal.Example:
bashCopy code$ pwd /home/user/Documents
List all files and directories (including hidden files):
Use the
ls
command to view the contents of the current directory.Example:
shellCopy code$ ls file1.txt file2.txt folder1 folder2 $ ls -a . .. .hidden_file file1.txt file2.txt folder1 folder2
Create a nested directory A/B/C/D/E:
Use the
mkdir
command with the-p
option to create nested directories.Example:
cssCopy code$ mkdir -p A/B/C/D/E
Change Directory (cd): Use the
cd
command to navigate to a different directory.Example:
shellCopy code$ cd /home/user/Documents
Remove Directory (rmdir): Use the
rmdir
command to remove an empty directory.Example:
shellCopy code$ rmdir empty_directory
Remove Files and Directories (rm): Use the
rm
command with the-r
option to remove directories and their contents.Example:
shellCopy code$ rm file.txt $ rm -r folder
Copy Multiple Files (cp): Use the
cp
command to copy multiple files to a destination directory.Example:
shellCopy code$ cp file1.txt file2.txt /home/user/Documents/
Move Multiple Files (mv): Use the
mv
command to move multiple files to a destination directory.Example:
shellCopy code$ mv file1.txt file2.txt /home/user/Documents/
File Permissions (chmod): Use the
chmod
command to change file permissions.Example:
shellCopy code$ chmod +x script.sh
Display File Contents (less): Use the
less
command to view the content of a file page by page.Example:
rubyCopy code$ less large_file.txt
File Count (wc): Use the
wc
command to count the number of lines, words, and characters in a file.Example:
shellCopy code$ wc file.txt 10 25 200 file.txt
Find Files (find): Use the
find
command to search for files or directories.Example:
arduinoCopy code$ find /home/user -name "file*.txt"
Create and Edit Text Files (nano): Use the
nano
command to create and edit text files in the terminal.Example:
rubyCopy code$ nano new_file.txt