x

UNIX Tutorial

NEXT

UNIX Tutorial – UNIX is one of the computer operating system, high-function, interactive, multi-tasking, multi-user operating system. UNIX originated at AT&T Bell Laboratories in the late 1960s. It is based on an open-architecture in which all interfaces and inter-process communication is standard. This simplifies expansion of the operating system and development of new system and application features. This UNIX tutorial is mainly prepared for the beginners to understand the basic concepts of Unix, Unix commands, Unix Shell Scripting.


Start Unix tutorial now

Unix Tutorial – Basics & Introduction:

The first version of Unix came from AT&T in the early 1970s (Unix is old!).Unix was developed by programmers and for programmers.Unix is designed so that users can extend the functionality To build new tools easily and efficientlyTo customize the shell and user interface….more…

Basic Unix Commands

Cat Command in Unix:

This command one of the most frequently used commands in Unix. This command is used to read the content of the files in the command prompt. Using “cat” command we will be able to only read the file. We cannot modify or update anything on the file….more…

Chmod Command in Unix:

This command is used to change the file permissions. Basically, this command defines who can do what operations on the files. By default, when we create the files, it will be created with Read & Write access to User and Read access to both group and others….more…

Cp Command in Unix:

copies a file into same directory with different names or copies a file into different directory with same or different names….more…

Diff Command in Unix:

This command is mostly used to compare the 2 files and shows the difference between the 2 files.First let’s see the content of the 2 files, so that it will be easy to understand how the diff command displays the results….more…

Directories Command in Unix:

The directories in the Unix File management is the storage of files. In other words, it can be called as folders in windows.All the directories in the Unix will start with “d” followed by permissions. By this we can differentiate which one is file and which one directory….more…

Gunzip Command in unix:

This command is used to un-compress the files which are compressed using gzip command….more…

Gzcat Command in Unix:

This command is used to view the content of the compressed file using “gzip” command. The contents can be viewed without un-compressing the zipped files….more…

Gzip Command in Unix:

This command is used to compress the files in order to reduce the file space. Usually when we compress the text files, it will reduce the file space to almost half of the original size. If the command “gzip” is successful then the file name will end with “.gz”. The “.gz” indicates that the file is compressed….more…

More command in Unix:

If the file size is very huge and when we use view command to open the file, it will take more time to load / open the file. During that time, we can use more command to look at the content of the file. The more command shows the first part of a file, just as much as will fit on one screen. Just hit the space bar to see more or q to quit….more…

MV command in Unix:

In Unix, we have an ability to move the files to different name or can move the file to different directory.The below command is used to move the file to different name within the directory….more…

Rm Command in Unix:

This command is used to remove the file….more…

Touch command in Unix:

This command is used to create the empty files in Unix system. The size of the file created using touch command will be 0 bytes. We will be able to add the contents into the file using vi command….more…

Wc Command in Unix:

  This command is used to find the number of lines, words and characters in the file….more…

Vi or View command in Unix:

In Unix to view the file, we can use vi or view command. If you use view command then it will be read only. That means you can view the file but you will not be able to edit anything in that file. If you use vi command to open the file then you will be able to view/update the file….more…

ls command in Unix:

ls:To lists the files and directories from the Unix directory.Options in ls command in Unix:ls -l :Long listing of files. List in long format, giving mode, number of links, owner, group, size in bytes and time of last modification for each file….more…

Man command in Unix:

man command is a help command in Unix. The main use of this command is to find manual information by keywords.man accesses information from the HP-UX manual pages.  This command is useful to,List all manual entries whose one-line description contains any of a specified set of keywords….more…

Operators in Unix:

-eq operator – To check whether variable 1 and variable 2 are equal.Ex:if [ variable1 -eq variable2 ]-ne operator – To check whether variable 1 and variable 2 are not eqal….more…

Arithmetic Operators in Unix:

In Unix we have capability to add, subtract, multiply, division of arithmetic values.1.+ (Addition) – To add values on any side of the operator.2.-(Subtraction) – To subtract right hand operand from left hand operand.3.*(Multiplication) – To multiply the values on either side of the operator….more…

File operations in Unix:

-s in Unix – To check whether file exists in the specified folder and it is not an empty file.Execution results:-f in Unix – To check whether exists from the given path. This will just check whether file exists or not irrespective of whether file has content or not. It will check for the files not the directories. See below the details….more…

Control statements in Unix:

If, elif in Unix:Below is the syntax of If, Else if, Else condition in Unix….more…

Advanced Unix Commands

GREP command in Unix:

This command is used to find the whether the search criteria is available in the file and if the search criteria matches then it will print the matching lines.The below example shows on how to search the keyword when we are not sure of the file name….more…

How to Grep for Multiple Patterns in Unix:

Using grep command in Unix, we can find multiple search patterns to find the matching files.Either we can provide the file name to grep or we can give “*.*” which will search from all files under the directory. We need to provide the search patterns within single quotes with pipe separated each other….more…


If Condition in Unix:

 If condition in Unix should start with “if” and end with “fi”. Every script should start with “#!/bin/sh” as mentioned below.If the first argument given while executing the script is “Red”, then it will print as Nethra else it will print as Sanjay. See below the details….more…

Passing Parameter to User Define Function in Unix:

Shell functions have their own command line argument.Use variable $1, $2..$n to access argument passed to the function….more…

Search and Replace in VI:

In Unix file, we will be able to search the particular keyword and replace it with different keyword globally.In the above example the keyword Selvarasu will be replaced with Pachamuthu in the file. The keyword “g” used to search and replace globally. That means it will replace the keyword all over the file….more…

Unix Shell Variables:

In Unix, there are two types of shell variables:System variables: Created and maintained by Unix itself. This type of variables will be defined in capital letters.User defined variables: Created and maintained by user. This type of variables will be defined in lower letters….more…

Whoami command in Unix:

This command is used to find out who (username) is logged into the server. In real time scenario, we might need to login as superuser to perform certain operations. This command would be useful to identify whether we have successfully logged out from the superuser or not….more…

Passwd Command in Unix:

This command is used to change the password. It will ask for old password and ask to choose the new password….more…

 Kill Command in Unix:

This command is used to kill the process which is running. We have to find the PID of the process which needs to be killed and pass that PID as argument.Kill -9 command This command is used to kill the process permanently….more… 

 Ps -Ef Command in Unix:

This command is used to find the PID (Process ID, Unique number of the process) of the process. Each process will have the unique number which is called as PID of the process….more…

 Df -k Command in Unix:

This command is used to identify the total allocated space, Used space and available space for the given filesystem in kilobytes. If the directory is not provided in the argument then it will display the free space on all mounted file systems….more…

Bdf Command in Unix:

This command is used to identify the list of filesystems available in the server, where it is mounted and corresponding disk space details in kbytes….more…

Ftp Command in Unix:

This command is used to transfer the files from one server to another server. All you need is the server name and corresponding credentials.Just type ftp space server name. It will ask to provide the user details and corresponding password.Once it is successful, use the put command to transfer the files….more…

 Find Command in Unix:

This command is used to find the files from the specified directory.Use the below command to find all the files named as “file.txt” from the specific directory. You need to provide the directory from which you are looking for the files….more…

Find And Remove the Files in Unix:

Using find command, we can find and remove the specific files. Use the below command to perform such operations.See below examples for more reference.First, we are searching the files “testing1.txt” using find command and we could see that the file is present under “rrr” directory….more…

 Date Command in Unix:

This command is used to know current time in the server.there are diverse options in date command to know month, day, year, hour, minute, second etc.To know the current month alone, use the command – date +%mTo know the current day of month, use the command – date +%d….more…

 Uptime command in Unix:

This command is used to know when the server was rebooted lastly. In other words, this command is useful to know how long the server is running since it is rebooted….more…

 Clear command in Unix:

This command is used to clear the contents from the current window and moves the cursor to the first line of the window. In other words, it is used to clear the screen….more…

Shift command in Unix:

The shift command is used to move the command line arguments to one position left. The first argument is lost when you use the shift command.Shifting command line arguments is useful when you perform a similar action to all arguments one-by-one, without changing the variable name….more…

Sort command in Unix:

The sort command is used to arrange the lines of text alphabetically. It will just sort the text alphabetically and displays in the command line. The content of the file will not be modified.There are many options in sort command. Below are the details….more…

Crontab command in Unix:

In Unix, you have the capability to schedule the jobs/scripts to run at the specified time.We can schedule jobs to run at the specified intervals like once a day or once a week or once a month or once in every hour/5 mins/ 10 mins/ 15 mins etc using crontab….more…

Unix Command Line Arguments:

Unix Command Line Arguments:$0 -Shows value of the command itself (program name),$1  – First command line argument,$2  – Second command line argument….more…

Unix Shell loops:

The Loop is one of the important control statement in Unix that enables you to execute set of commands repeatedly. The following type of loops are mostly used in Unix Shell.For loop,While loop,Until loop….more…

Unix Shell functions:

Function is a series of instruction/commands. Function performs particular activity in shell i.e. it had specific work to do or simply say task.When program gets complex we need to use divide and conquer technique. It means whenever programs gets complicated, we divide it into small chunks/entities which are known as functions….more…

Unix Shell Scripting:

Let’s see simple script which prints the sentence that we written in the script.Create the file called myScript.sh which will print Hello World!….more…

Unix keyboard shortcuts:

Esc :=  à  After opening the file, Press Esc button and colon (:) and equal symbol (=) will give you the total number of lines in the file.Esc :q!   à After opening the file, if you press Esc colon and letter q and exclamatory symbol (!), will quit the file without saving….more…

NEXT



Like it? Please Spread the word!