Linux Commands for a Beginner
List of Linux commands for all the beginners
Creating a directory in Ubuntu OS 22.04 LTS named sample
mkdir sample
Changing path to the sample directory and creating a file named sample.txt
cd sample
touch sample.txt
Checking for the current path that we are on:
pwd
Checking the information on a file such as inodes, locations and symbolic links
stat sample.txt
Adding a user named user1 to the group called devops
useradd -a -G devops user1
Creating a softlink for a file named sample.txt
ln -s sample.txt sample_link_shortcut.txt
Lets Copy the file
cp sample.txt sample1.txt
Listing out the groups within the OS:
groups
List out the users present on the OS:
cat /etc/passwd
List out the files and folders along with their permissions and any hidden files:
ls -ahl
Find a file that is greater than 25MB:
find . -type f -size +25M
List out the contents of a file:
cat sample.txt
List the contents of a file in the reverse order:
tac sample.txt
Find a pattern or a word that exists and in the file sample and replace it with another word
sed -i 's/tokan/token/g' sample.txt #(the -i stands for --in-place tag)
Display contents of a file such as dnf.log present in the /var/log folder.
less /var/log/dnf.log
Display contents of a file such as dnf.log present in the /var/log folder.
more /var/log/dnf.log
Find pattern or a word within a file
grep -i 'centos' sample.txt (i is for ignore case)
grep -r 'centos' sample.txt (r is for recursive)
Deleting or removing a file:
rm sample.txt
Deleting or removing a folder with contents:
rm -rf sample (To be very very careful when using during production)
The above command should be used carefully and only individuals who are authorized to access production should be given permissions, the results tend to be devastating otherwise.