DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

Smithan kumar R
Smithan kumar R

Posted on • Updated on

Everything You Need to Know About Unix Commands

UNIX, 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
Enter fullscreen mode Exit fullscreen mode

Result: Lists the names of files in your default directory, in alphabetical order.

Example: ls -l
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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 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 {these changes the current }
Example:  cd .. {here it comes out of the present directory}
Enter fullscreen mode Exit fullscreen mode

mk-dir β€” This command is used to make or create a new file or new directory in the specified path.

Example: mk-dir
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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 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
Enter fullscreen mode Exit fullscreen mode

Result: Displays the contents of the file β€œnew file” on your terminal.

Example:  cat new file old file
Enter fullscreen mode Exit fullscreen mode

Copying Files:

cp – Makes copies of your files. You can use it to make copies of files in your default directory, to copy files from one directory to another directory, or to copy files from other devices.

Example: some cp file one file two
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Result: Changes the name of the file β€œold file” to β€œnew file.” Only one file will exist.

Top comments (2)

Collapse
ccoveille profile image
Christophe Colombier

Good article for beginners, but your title is wrong for me.

Everything You Need to Know About Git Commands

You are not talking about git in this article.

BTW, I would suggest you to add tags to your article

Collapse
smithankumarr profile image
Smithan kumar R Author

Thank you for your Suggestion

🌚 Browsing with dark mode makes you a better developer.

It's a scientific fact.