In this article we would discuss some basic linux commands. These commands require to perform normal tasks. Make familiar yourself with these commands. In our previous article we have create a normal user now login from that user.
In bracket right most side is showing user name Vinita and beside @Server is the hostname of computer and further ~ sign is showing that user is presently logged in her home directory. But first, every Linux user has a home directory. You can use the tilde (~) to represent the home directory of any currently active user. For example, if your username is Vinita, your home directory is /home/Vinita. If you have logged in as the root user, your home directory is /root. Thus, the effect of the cd ~ command depends on your username. For example, if you have logged in as user Vickey, the cd ~ command brings you to the /home/Vickey directory. If you have logged in as the root user, this command brings you to the /root directory. You can list the contents of your home directory from anywhere in the directory tree with the ls ~ command. After bracket you can see the command prompt of normal user is $ sign.
mkdir command is used to create new directory. Let’s create a example directory.
$mkdir example $ls example
now create a file. Syntax for creating file is
$cat > [file name]
This command can be used in three way
To see the contents of file
To create a new file
To append the contents of file.
$cat [file name] ------------------------ To see the contents of file $cat > [file name]---------------------- To create a file $cat >> [file name ]-------------------- To append the contents of file
Be little bit careful while using cat > command to create new file. If you accidently used this command with existing file it will overwrite the contents of file. Use CTRL+D to save the contents of file.
Different use of cat command
$cat > test This is test of file $cat test This is test of file $cat >> test This is second line $cat example This is test of file This is second line in test file $cat > test Now file will over write $cat test Now file will overwrite
It is easy to change directories in Linux. Just use cd and name the absolute path of the desired directory. If you use the relative path, just remember that your final destination depends on the present working directory.
as you can see in the output of ls command file is in white color and directory is in blue color.
There are two path concepts associated with Linux directories: absolute paths and relative paths.
An absolute path describes the complete directory structure based on the top level directory, root (/).
A relative path is based on the current directory. Relative paths do not include the slash in front.
The difference between an absolute path and a relative one is important To know more about path and directory structure
In many configurations, you may not know where you are relative to the root (/) directory. The pwd command, which is short for print working directory, can tell you, relative to root (/). Once you know where you are, you can determine whether you need to move to a different directory.
this command is used to exit from current directory.
The cp (copy) command allows you to take the contents of one file and place a copy with the same or different name in the directory of your choice. For example, the cp file1 file2 command takes the contents of file1 and saves the contents in file2. One of the dangers of cp is that it can easily overwrite files in different directories, without prompting you to make sure that's what you really wanted to do.
You can't rename a file in Linux, you can move it. The mv command essentially puts a different label on a file. For example, the mv file1 file2 command changes the name of file1 to file2. Unless you're moving the file to a different partition, everything about the file, including the inode number, remains the same.
rm command is used to remove the regular files. It will ask before removing files.
it will remove the empty directory. If directory is full then use rm –rf [directory name]
Search more about
Search in Google for