What is shell in linux ?
Shell is command line interpreter, that directly interacts with the operating system.
Let us start with basic linux commands.
open your Terminal. Shortcut alt+ctrl+t.
To know which shell you are currently using type the following command in your terminal. echo $SHELL .
To know the version of your version of your shell just type away /bin/bash –version.
Creating Directory : mkdir directory-name . mkdir – is make directory and name specifies your directory name, Directory normally refers to folder in windows.
So now we have created a new directory in our system and want to get into the new directory
change directory : cd directory-name . Tips instead of typing the whole directory name just type the first few letters of directory name and press tab key in your key board. It will complete the rest of the directory name. cd – change directory.
List files and directories in the current directory: ls . This command will only list the visible directories and files ( not hidden). In unix / linux system normally .(dot) files are hidden files. Any file or directory name starts with .(dot) are considered as hidden files. To view all the files including hidden files you need to specify one more arguments with list commandls command. This one ls -a.
Here you have listed all the files and directories that are present in current directory. Directories and files are in different color. Here you will find two hidden files (.) and (..) . These files are present in all directories (.) represents the current directory, you want to try just type cd . again you will in the same directory, and (..) represents the parent directory of current directory, just type cd .. and you will come out of your directory. cd .. is normally used to get out the directory.
And how to check file attributes : ls -l. This command list all files excluding hidden With attributes.
for eg : drwxrw-r-x 1 owner group size month day time filename
Field 1: A set of 10 permission flag
Field 2: number of links the file have
Field 3: Owner of the file
Field 4:associated group for the file
Field 5: size in bytes
Field 6-8: date and time of last modification
Field 9: name of file
Field 1 : This is quiet different. A set of 10 permission flag.
permission 1 : d– this indicates whetherit is directory or not(-). If it is not a directory then – will be present.
permission 2-4: These permissions are for owner of the file r-read, w-write and x- execute permission. If they are present the owner has permission to do else – he doesn’t.
permission 5-7: These permissions are for group of the file r-read, w-write and x- execute permission. If they are present the group has permission to do else – he doesn’t.
permission 8-10: These permissions are for other users of the file r-read, w-write and x- execute permission. If they are present other users has permission to do else – he doesn’t.
This is it about listing directories you can even use both ls -l and ls -a together like this ls -la
Removing the directory:
rmdir directory-name. rmdir – remove directory. This only removes the empty directory, if there is any files or directories present inside the directory it will not delete it and it produce error: Error messagefailed to remove : directory is not empty.
So how to remove the directory with content, this command helps you rm -r directory-name. It recursively (-r for recurs) removes the content inside the directory and finally delete the directory.