Posts

Showing posts with the label beginner

How to print lines matching pattern or string ?

Image
Consider you have a file called dictionary.txt with a huge collection of words and you only want to view line containing the word "tux". To check each word line by line is a tedious task, instead we use the grep command.

How to find location or path of a command

In our earlier posts we saw how to find the location of a file with locate command and find command. But how do we find the path of a command in Linux? For that purpose we use the following commands which whereis

How to compare two file ?

In Linux we can compare whether two files are the same or not using more than one command. They are cmp command diff command sdiff command

What are the different link files in linux ?

Image
A file in Unix/*nix environment consist of two part, a filename part and a data part.  File name is just a reference or a link to the data part. The data part is known as i-node and it is the i-node of a file which stores the information regarding the file like file permission, file location, file size etc... Usually a file's data is accessed by calling the filename. But there are methods by which same data can be accessed using several names. We call these methods Link. Links are divided into 2 types. They are

Linux File System

Image
Just imagine an office environment before the arrival of computers.  All the data connected with the office will be available in paper and kept in a file. In a big organization there will be thousands of file. It will be hard to keep track of all these files unless all the files are kept safely and well organized. This not only helps to track a file easily but also improves work efficiency of the place.  Now lets co-relate the scenario with a computer. Instead of paper files, in a Computer System

How to search and find location of a file in linux ?

In linux there are mainly two methods by which a file's location can be searched. They are locate command find command

How to remove a file in linux ?

rm is one of the basic commands used to remove a file in linux. rm can be used to remove a file, directory, device nodes, links and so on.The rm syntax is given below

How to move or rename a file in linux?

mv (short form for move) command is the linux command used to move a file from one location to another. Just like moving the file location, mv can move file names from one name to another. i.e with mv command can be used to rename a file. The syntax for mv command is as follows

How to copy files or directories from command line in linux ?

For copying files and directories from command l ine we use cp command. The Syntax for cp command is as follows

How to view only first or last few lines in linux ?

In the previous post we saw how to view / display the contents of a text file with more and less commands. What if you don't want to view the entire file contents? Say, you want to view only the first 10 lines of the file. Or you want to see only last few lines of the file. For that purpose we use the commands head and tail.

How to view or display contents of a file in linux one screen at a time?

Image
more and less are paging commands used in Unix/*nix systems to display contents of a file one screen at a time. The difference between more and less is that, less supports both forward and backward navigation through a file. Whereas more supports forward navigation but backward navigation is very much limited.

How to edit a text file from command line in linux ?

In Unix/*nix vi is the standard and widely used commands to edit/create a plain text file from the command line. vim (Vi IMproved ) is another text editor based on vi which can be run from a Command Line Interface as well as a Graphical User Interface. 

Linux Wildcards - Standard

Image
" Unix is simple. It just takes a genius to understand its simplicity. " – Dennis Ritchie One of the advantage of Unix or *nix operating system is its simplicity. Beginners might find it hard to agree with me. But once you have familiarized with the OS and learned how to make use of it, you will discover the simplicity offered by Unix / *nix operating systems. Wildcards are one such concept which make Unix / *nix simple

cat command

cat command is one of the basic linux commands used to concatenate and write files. cat command can be used for the following major purposes View text files Create text files Append, Combine text files Copy a text file  

How to list contents of a directory ?

To list the contents of a directory in linux use the ls command. ls command when used with out any argument will display the contents of the current directory.

How to create a directory in Linux

Image
  In order to create one or more than one directory in Linux we use the command mkdir . For creating a directory you type mkdir followed by the directory name.The command will create a new director y , provided a directory by the same name do not already exist . The syntax to create a directory in Linux is as shown below

What was that command again?

Image
What will you do if you forgot the command name you want to run on your Linux box? Yeah, right! You will google it. But what if you have no access to internet. Don't worry apropos command is there to save you.  The command apropos which means appropriate or relevant in English search the man pages and its description for a keyword and display them on the screen. This command is useful when you are not sure about the exact command you want to use.

Linux Basic Commands

Wi th my first  post I am adding some of the basic and most frequently used Linux commands . Most of th e commands mentioned here can be used in numerous methods. Detailed usage of each com mands will be the sub ject of my next posts.