Linux Operating System Intro and Terminal Commands || CODELABS3277

Intro to the Linux :

Linux is a family of free and open-source software operating systems built around the Linux kernel. Typically, Linux is packaged in a form known as a Linux distribution (or distro for short) for both desktop and server use. The defining component of a Linux distribution is the Linux kernel, an operating system kernel first released on September 17, 1991, by Linus Torvalds.

Why to use Command Line?

If you're like many Unix users these days, you probably use a GUI (graphical user interface) for Unix, with windows and a mouse. Even Macintosh users have Unix underneath their gorgeous GUI, thanks to Mac OS X.

Here we will be Learning about How to do the things in Ubuntu using CUI (Character User Interface/Command line User Interface) .


  •  To know directory in which you are now 
  • Type and Press Enter the below command:

$pwd




$ls  - You can use this for seeing the list of files or folders present in your current working directory.



$cd Desktop - cd stands for change directory, using this command you can change to the required directory.



$mkdir <name of the file> -using this you can create any directory.



See the desktop screenshot below and above command , your required folder has been created.



Changing directory to the newly created Linux_Command folder



$gedit & -to open the linux text editor . //&- sign is necessary



$gedit Linux_Commands.txt  - Using this command you can both make and save text file.



Ctrl + C   -is used to terminate the application file which is being opened thats why we don't use Ctrl + C for copying text in terminal window.



See here your Linux_Commands.txt file have been created inside the Linux_Command folder.



$libreoffice & -This will be used to open the office suite of Linux. It is same as your Windows Microsoft Office Package.



You have to manually type the name of file and save using GUI (Graphical User Interface). There is know other method to do this.



$ls  - You can use this for seeing the list of files or folders present in your current working directory.



$cd ..   -This command you use for going one directory back as shown in the example in which we go from Linux_Commands to Desktop.  Take care that there is space between cd and ..

$cd  -You can use this to going back to your parent directory i.e Home directory.



$ls  - You can use this for seeing the list of files or folders present in your current working directory. Here you see that file1.odt is present. After using the next command it ill be removed.



$rm file1.odt  -This command is used to delete the file. Now before  deleting this I have made copy in my desktop and copied it back to perform the next operation so you will be able to see the file .

There are more method to delete the file such as force deletion, recursive deletion, recursive-forced deletion. About these I will be talking later in the page.


$cp file1.odt /home/amar/Desktop/  - This command is used t copy the file from current directory to the destination directory. 



Now you can go to the desktop directory and check for the copied file. And also see the command that after copying I have removed the file using rm command.



$mv file1.odt /home/amar/Desktop/  - This command is used to move the file from current directory to the destination directory.  The difference and copying and moving is in copying duplicate file is created and in moving no file is created.



See here file1.odt is not present here. 



See here file1.odt is  present here in the desktop folder. 



$gvfs-trash file1.odt  -using this command you can move the folder to the trash i.e. Recycle Bin of Linux OS .The file is being deleted temporarily. (This is not used for Mac OS X)

Other command for doing the same is ;

$gio trash file1.odt // This may not work in old Linux Distribution.



You can see your file in Trash.



Temporary file deletion using gio trash.



See your file in Trash.



$mkdir PPT ODF ODS  - This type of syntax is used for creating multiple directory in one command.



See the files which you have created now.


To move the file in their  respective folder I have used multiple mv command.


Now the directory is made clean by moving the files to folder.


$mv file1.odt file2.ods file3.ppt /home/amar/Desktop/Linux_Command/LinuxPracticeCopy/ .  This is used for moving multiple file at ones to the destination folder.



Go and check for the files in LinuxPracticeCopy for your required file.


$rm -r LinuxPracticeCopy/ .  Now since this directory contain another directory inside it so it cannot be deleted by using the simple command $rm.  To delete this type of folder we use the concept of recursive deletion.

-r  stands for recursive. There are other methods also:
-f  stands for forced .  //used to delete the file forcefully
-rf  stands for recursive forced.  //used to delete the directory forcefully
-i  stands for interactive.  //used to delete in Interactive way that is the system will ask you that are you sure to delete the file . Type Y/y for us else N/n .

Instead of -r in above command use any one of the following at a time.


Warning: when you will try to delete the folder containing subfolder using gvfs-trash command. For this you should use gio trash. After this situation also your file will be deleted temporarily. Making a Copy.



See you both deleted file and copied file.


$ gedit file4.txt file5.txt file6.ppt file7.ppt file8.doc  -To create multiple files at same time.



After typing the above command your text editor will pop up like this . Now you just have to press Ctrl+S , to save the file.



Now you can see that your files have been created.



SEARCHING FOR THE FILE:

Using find command to search for the file.

$find D*   -This command is used to find all the file and folder whose parent folder name starts from D.

 $ find -name *.txt      -This command is used to find all the file has extension as .txt any where in the computer.

$find -name fileName  -Use this to find the file if you already know the name.


 Using ls to search file.

$ls *.txt -Used to find .txt file in current working directory.
$ls *.ppt -Used to find .txt file in current working directory.





 Restoring Files from the TRASH 

To restore files lets first delete it Temporarily.
I will be using gio trash for this .
$gio trash file1.odt - This deletes the file Temporarily. 


Now to Restore from the Trash follow the Steps of command: 

$ cd .local/share/Trash/files  -This command takes you to the trash through root user path. There are another files in trash but the file which we delete goes to files part of trash.

After this use move command to move your file to Desktop .
$mv file1.2.odt ~/Desktop/ -Moves the file.

File you have got after restore.

Thanks For Reading.

If there is any error ,let me know through the comment section.

Comments