Everything You Need to Know About Unix Commands

smithankumarr

Smithan kumar R

Posted on August 16, 2022

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.

💖 💪 🙅 🚩
smithankumarr
Smithan kumar R

Posted on August 16, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related