Skip to main content

Command Line Part 1


Lecture 01 Commands Line introduction

Let's find all HTML files:
$ find . -name "*.html"
 




Extended Eg

Let's ensure that all our html files use HTML5
$ find . -name "*.html" -exec grep -i 'doctype' {} \;
 
 





Commands

ls

  • The command ls lists the files in a directory.
  • The command is documented in the manual
$ man ls
(Hint: type q to quit the manual).


Options

Most commands take options. For example:
  • -a, --all do not ignore entries starting with .
  • -1 list one file per line. Avoid '' with -q or -b
So we may
$ ls -a -1
$ ls -a1
$ ls --all -1

 

Piping

Piping using the | allows combining commands.
$ rpm -qa
lists all the installed packages on a RedHat/Fedora system.
$ rpm -qa | grep -i "Acrobat"
searches the list to see if the Acrobat PDF reader is installed.

 Note: the try with acrobat doesnt work because I do not have install any PDF since I'm just using an emulator (Virtual Machine) and I have not install anything on it.

Complex Eg

How do you list all the software licences of packages installed on your system?
$ rpm -qa --qf "%{license}\n" | sort | uniq
 

Filesystem

Try

$ cd ~
$ ls
$ ls -a
$ cd Documents
What does the -a option for ls do?

 -a includes the files, since ls only include carpets

Conclusion

  • There are many Linux commands.
  • Each command has options.
  • Some commands take other parameters.
  • Commands can be combined quickly to give impressive functionality.
  • The filesystem makes more sense than the Windows structure!

Comments

Popular posts from this blog

What is Eclipse IDE and how to install

What is Eclipse? Eclipse is an integrated development environment (IDE) used in computer programming, and is the most widely used Java IDE. It contains a base workspace and an extensible plug-in system for customizing the environment. Eclipse is written mostly in Java and its primary use is for developing Java applications, but it may also be used to develop applications in other programming languages via plug-ins, including  C, C++, Fortran, JavaScript,  and others. Development environments include the Eclipse Java development tools (JDT) for Java and Scala, Eclipse CDT for C/C++, and Eclipse PDT for PHP, among others. How to install Eclipse Step 1: First we are going to download Eclipse at their website, make sure you select the correct OS. Step 2: After you finish downloading it you will get a Zip file with the name of the Eclipse you just download, open it and extract it and after that you are going to run it and this is going to be ...

What is the 'Oracle Virtual Machine' and how to install it

What is the Oracle Virtual Machine? VirtualBox is a powerful x86 and AMD64/Intel64  virtualization  product for enterprise as well as home use. Not only is VirtualBox an extremely feature rich, high performance product for enterprise customers, it is also the only professional solution that is freely available as Open Source Software under the terms of the GNU General Public License. In other words is an emulator for Operative systems, for example if you have a Windows 10 and you want to have Linux or any other without going through all the complicated installation process then you can just install it with the emulator assigning the amount of space and resources that you want to use on it. How to install the Oracle Virtual Machine (OVM)  Step 1: Download the OVM from the main page: Step 2: Select the operating system you are going to be using to host the OVM Step 3:  Install, After you...

If and else statements on Shell/Linux Terminal

If and Else if and else are conditions statement that can be very useful and we are going to learn how to use them, lets first start our terminal and create a file in which we are going to create a simple security password program We are about to create our script I have name it test and we are going to type the following we are going to create a variable called VALID_PASSWORD with the value "secret", this means our password is secret (yes the actual password is secret), then we are going to read the value the user introduce with read PASSWORD the if statement here will compare what the user introduce in PASSWORD with VALID_PASSWORD!, IF they are equal then it will print you have access if not then it will print ACCESS_DENIED! is very important to close the IF statement with an 'FI' (FI closes the IF statement) I hope this was useful and detailed enough to help you understand how does if and else works. to try this all you need is 'bash...