D03- Basic Commands in Linux

 Why learn commands?

  • We learn it because it makes file management in Linux easier.
Commands are also referred to as "Programs" because whenever we run a command, its actually the corresponding program code we are writing.

Basic Linux Commands:

Listing Files- (ls)
  • it shows the files and directories in the current directory or in the directory where we are presently working.
Listing all the files of a directory and their subdirectories- (ls -R)
  • this command not only the files in the directory but also their subdirectories.
  • note that the command "ls-R" is case sensitive and if we write the letter r in a small case, "ls-r", it will throw an error.
Listing all files- (ls -al)
  • it gives us detailed information about the files.
  • this command provides information in a tabular format.
  • The detailed information includes permission, owner, groups, date and time, file sizes, etc.
  • It also shows us the hidden files.
  • Hidden items in Linux begin with the "." period symbol at the start, of the file or directory.
  • Any directory or file starting with a "." will not be seen unless it is requested.
Creating and viewing file- (cat)
  • Can be used for copying, combining, and even creating new text files.
  • cat>filename will enable us to create a new file.
  • To view the file which you created, you can use the command cat filename.
  • To concatenate the two files, we can use the command cat filename1 filename2 > filename3.
  • Only text files can be combined and viewed using this command.
The terminal is a silent type. It never gives you a message if your commands are successful but will if your commands have an error.

Deleting files - (rm)
  • rm filename will delete the file.
  • it does not ask us for confirmation.
The command mv can be used for many different things.

First, it can be used to move things from one directory to another.
Secondly, it can be used for re-naming files as well:
  • mv filename newfilename will have changed the name from filename to newfilename.
  • mv can also be used for changing the names of the directories.
An important thing to keep in mind is that after getting into the root user using the command sudo, the terminal by default will retain the entered password for at least 15 minutes.

Directory Manipulators- (mkdir)
  • mkdir directory will create a subdirectory in the present working directory, which is usually the "Home Directory".
Removing Directories- (rmdir)
  •  rmdir mydirectory will delete the directory mydirectory.
Global Regular Expression Print- (grep)
  • it is used to search text in files and print that matches the given pattern.
Other important commands to keep in mind:
  • history command will display all the commands used in the past for the current terminal session.
  • clear command will clear the terminal and give you a lean window to work on.
  • vi or vim is a terminal-based text editor that you can use to write any files.
  • gedit is a GUI based text editor.
A visual representation of the basic linux commands:




Comments

Popular posts from this blog

Topic D02 Introduction to Linux

EO2-Linux Network and Process Managment

Topic D01- Container Technology