Linux Command Cheatsheet For Beginners

In this tutorial you’ll learn basic and the most used Linux commands. This Linux Command Cheatsheet For Beginners will help you gain the necessary understanding of daily task execution through the terminal.

Linux is the preferred Operating system among professional developers because it makes very efficient use of the system’s resources.

Linux Command Cheatsheet

The commands discussed below may not help you become a pro in a day, but practicing all and learning new things along with implementing everything in a positive manner will make you an efficient Linux user.

1. File Management

lsLists all the files in the current directory
ls -lShows files along with permissions
ls -alShows a list of all the files including hidden Files
ls -ltSorting the listing by time modification
pwdShows the Present Working Directory
cdPrints Current Directory
cd ..Change the directory to the parent directory
cd –change to the previous directory
cd dir_nameChange the directory to “dir_name”
mkdir dir_nameMake a directory with “dir_name”
cat > filenameCreates a new file with ‘filename’
cat filenameDisplays file content
cat file1 file2 > file3Concatenate or joins two files in one
touch filenameCreate a new file with ‘filename’
rm filenameRemoves the file
rm -r dirRemoves a directory named ‘dir’
cp file1 file2Copy file1 and call it file2
cp -r dir1 dir2Copy contents of directory ‘dir1’ to ‘dir2’
mv file1 file2Move file1 to file2
echo ‘Hi’ > data.txtEnters content to a file
echo ‘There!’ >> data.txtAppend text to existing file in Linux
nano filenameOpens file in an editor
vim filenameEnables efficient text editor
tar -cvf archived.tar /indgeekCompress files and folders in Linux
tar -xvf archived.tarExtracts the tar archive file

2. Management Commands

sudoAllows regular users to run with Superuser privileges
apt-getCommand used to install and update packages
ps Displays the current working processes
manOpens the help manual of a command
pidofGives the Process ID (PID) of a process
kill PIDKill the process with the given PID
top -u igeekDisplay specific User process details
niceStarts a process with a given priority
reniceChanges priority of an already running process
dfGives free hard disk space on your system
freeGives free RAM on your system
bgTo send a process to the background
fgTo run a stopped process in the foreground

3. Permissions

Linux permissions grating is a tricky task that you may memorize with simple syntaxes.

Remember providing ‘Read Permission‘ to any user would only allow them to read the file, that specific user won’t be able to write/ modify or execute that file or application.

Users:

Every file and directory on a Linux system can be assigned 3 types of Owners,

  • Owner: The Owner is the creator of a specific file or Directory
  • Group: A Group can contain multiple users
  • Others: A person who has neither created the file nor belongs to a user group who owns the file.
uuser/ owner
ggroup
oother
aall
+Adds permission
Removes permission
=Assigns the permission
rRead Permission
wWrite Permission
xExecuting permission
0– No permissions
1-x
2-w-
3-wx
4r-
5r-x
6rw-
7rwx
chmod +rwx filenameAdds all permission to an user
chmod -rwx filenameRemoves all permission from an user
chmod +w filenameAllows users to modify the file
chmod +r-x filenameAllows a user to read and execute
chmod 777Completely permits Owner, Groups, others
chown userChangs the ownership of a file/directory

4. System

usersShows the username of users currently logged in
wDisplays who is online
whoamiDisplays current logged in user to this system
finger userShows information about the user
sudo adduser usernameAdds a user with a username
sudo userdel -r ‘username’Removes ‘username’ user
sudo passwd -l ‘username’To change the password of a user
sudo usermod -a -G Gname UnameAdd user to a Group
uname -aShows Kernal information
uname -mShows Architecture information
cat /proc/cpuinfoDisplay CPU information
cat proc/meminfoDisplay memory information
free -tShows total memory used & available

Also Read: Advantages of using Linux

5. Searching

grep pattern filename Search for “pattern” in the file
grep -i “indgeek” geeks.txtEnables to search for a string case-insensitively
grep -c “igeek” geeks.txtDisplaying the count or number of matches
grep -r pattern dirSearch recursively for patterns in dir
locate filenameFind all instances of file
grep -v “igeek” geeks.txtDisplay the unmatched lines with the searched pattern
find . -name geeks.txtFind all the files whose name is geeks.txt in PWD
find / -type d -name IndGeekFind directories whose name is IndGeek in / directory

6. Networking

ssh [email protected]Log into the Remote host at a specific address as user ‘igeek’
ftp 192.168.10.3Connects to remote FTP host
ping indgeek.comTo ping and analyze network and host connections
ifconfig -aDisplay network information
netstatShows active or listening ports
whois domainGet whois information for a domain
dig domainGrabs DNS information of a domain
dig -x hostReverse lookup host
wget filenameDownloads file
wget urlDownloads file from a specific URL
put fileUpload ‘file’ from local to the remote computer
get fileDownload ‘file’ from remote to local computer
quitLogout as a user
Sharing Is Caring:
Editorial Staff

An aspiring BTech Electronics and Communication student, obsessed with Coding, Gadgets, Blogging, & Digital Marketing.

Leave a Comment