10 Most useful Linux commands
cat
: - It can read, concatenate, and write file contents to the standard output.Syntax: cat [options] file_name
cat -n
: add a number line to each line.cat -e
: add $ at the end of the line.
cat file1.txt file2.txt
: concatenate files content in the sequence they are passed.
chmod
: used to change the access permissions of files and directories.It takes three main arguments: r, w, and x, which stand for read, write, and execute, respectively.u: User, meaning the owner of the file.
g: Group, meaning members of the group the file belongs to.
o: Others, meaning people not governed by the
u
andg
permissions.a: All, meaning all of the above.
r: Read permissions. The file can be opened, and its content viewed.
w: Write permissions. The file can be edited, modified, and deleted.
x: Execute permissions. If the file is a script or a program, it can be run (executed).
history
: list down all the commands you have used till now.history 10
– Will give you the last 10 executed commands.rm
: used to remove files/directories. To remove a folderrm
use-r
as a folder is a combination of files/directories so we need to delete recursively.
touch
: use to create empty files as well as update existing files/directories' timestamps.-c
: no new file is created .it only changes the timestamps of an existing file.-a
: updates the access time.-m
: change both modify time and change time of an existing file.
ls
: used to list all the files/directories present in the current working directories.-l
: tellsls
to print files in a long listing format.-a
: display all files including the hidden files.-R
: display the contents of the subdirectories recursively.-1
: produce listing in a single line.-A
: display all files including the hidden files except.
and..
tail
: displays the last part (10 lines by default) of one or more files.-n
: to specify the number of lines-c
: to specify the number of bytes
head
: works similarly totail
command just print data from top .just replace thetail
withhead
command.diff
: helps to find out the difference between two files.grep
: stands for Global Regular Expression Print. it is a tool used to search for a string of characters in a specified file.it is case-sensitive-w
: to search for the exact match of the given word.-i
: ignore the upper and lower case while searching.-c
: print how many times the given keyword is present in the file.-v
: search everything except the given pattern/keyword.-n
: prints the line no of matches of a given keyword in a file
Thank you for reading!!
Great initiative by the #trainwithshubham community.