Linux Admin Commands

  • In Linux, a file is always associated with timestamps, and every file stores the information of last access time, last modification time and last change time. So, whenever we open or modify a given file, its timestamps change.
  • Touch is one such command if we wish to fiddle around with the file timestamps.
  • grep searches for PATTERNS in each file. PATTERNS are one or more characters separated by newline characters, and grep prints each line that matches a pattern.

Summary of commands

  1. touch: This command is used to change the timestamps (the last access time, the last modification time and the last change time) of a file. If no file is present in the system and passed as an argument, then the command will create a file without any type of content inside it.
  • touch -a filename: This command is used to change the access time of a file.
  • touch -m filename: This command is used to change the modification time of a file.
  1. find: This command is used to search for a file in the file system by using some criteria such as the file name, the last access time, the last modification time, file permissions or the owner or size of the file.
  2. grep: This command is used to search for a string of characters in a file. If the string is found, the command will print all the lines containing the string. We can also use this command as follows:
  • grep -i “string” filename: This command makes the string case insensitive. For example, the command will treat “upgrad”, “UPgrad” and “upGRAD” in the same manner.
  • grep -c “string” filename: This command can be used to find the number of lines containing the string.
  • grep -v “string” filename: This command can be used to display the lines in a file that does not contain the string.
  • grep -l file1 file2 file3: This command can be used to display the name of the file out of multiple files containing the string.
  1. sudo: Linux does not allow all users to access some parts of the system in order to prevent sensitive files from being compromised. This command can be used to access such restricted files and operations. It temporarily elevates the privileges of the users and allows them to complete sensitive tasks without logging in as the root user. This command asks you for your personal password and confirms your request to execute a command by checking a file. Administrators can provide certain users or groups with the access to some or all commands without requiring those users to know the root password. Note that all the user information is stored in the sudoers file.

Try them out!

Ubuntu
Debian
Symbian
Windows
OS
Linux
Android
sort -r os.txt
Windows
Ubuntu
Symbian
OS
Linux
Debian
Android
Ubuntu
Debian
Fedora
Symbian
Windows
OS
Linux
Fedora
Android
sort -u os.txt
Android
Debian
Fedora
Linux
OS
Symbian
Ubuntu
Windows
Delhi is one of the most important cities in India. 
It has a wide variety of arts & cultural centers.
Delhi is also surrounded by a river on its periphery.
sed 's/Delhi/Kolkata/' city.txt
Kolkata is one of the most important cities in India. 
It has a wide variety of arts & cultural centers.
Kolkata is also surrounded by a river on its periphery.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store