Get to know about Unix commands
Some of the basic commands of Unix for best practice
Photo by Raphael Nogueira on Unsplash
UNIX is a multiuser computer operating system. The main features of UNIX were its simplicity, portability (the ability to run on many different systems), multitasking and multiuser capabilities, extensive library of software, and hierarchical file system.
Displaying a Directory: ls–Lists the names of files in a particular Unix directory. If you type the ls command with no parameters or qualifiers, the command displays the files listed in your current working directory. When you give the ls command, you can add one or more modifiers to get additional information.
Example: ls
Result: Lists the names of files in your default directory, in alphabetical order.
Example: ls -l
Result: Gives a long listing of the files in your directory. In addition to the file name, the long listing shows protection information, file owner, number of characters in the file, and the date and time of the last change to the file.
Example: ls -a
Result: Causes all your files to be listed, including those files that begin with a period (i.e., hidden files).
For more information, type Man ls at the Unix system prompt.
To create and change the directory: This is used to change the current directory and also move from one directory to another directory.
Example: cd {these changes the current }
Example: cd .. {here it comes out of the present directory}
mk-dir — This command is used to make or create a new file or new directory in the specified path.
Example: mk-dir
rm-dir — This command is used to remove the created directory and by using rm-dir -r (recursively delete all the files present in that directory)
Example:rm-dir
Manipulating files using CRUD{Create, Read, Update, Delete}
Some of the commands to Know:
Touch — This command is used to create a new file.txt
Echo — It is used to print the statement or add a new line that the file
Head — It is used to display the first ten lines of the file
Tail — It is used to display the Last Ten Lines of the file
Nano — It is an inbuilt editor used to edit the file
Grep { global regular expression } — used to find the specific in the given file Displaying and Concatenating (Combining) Files: cat — Displays the contents of a file on your terminal.
Example: cat new file
Result: Displays the contents of the file “new file” on your terminal.
Example: cat new file old file
Copying Files: cp – Makes copies of your files. You can use it to make copies of files in your default directory, copy files from one directory to another directory, or copy files from other devices.
Example: some cp file one file two
Result: Copies the contents of file one to a file named file two. Two separate files now exist.
Deleting Files: rm–Deletes specific files. You can enter more than one file name on a command line by separating the file specifications with spaces.
Example: rm new file
Result: Deletes the file named “new file.”
Renaming Files: mv–This command changes the identification (name) of one or more files.
Example: mv old file new file Result: Changes the name of the file “old file” to “new file.” Only one file will exist.
Thanks for reading. Please share your experiences, questions, and feedback below!