LINUX TERMINAL COMMAND – EXPLORE THE SYSTEM







Now that we know how to move around the file system, it's time for a guided tour of our Linux system. Before we start however, we’re going to learn some more commands that will be useful along the way: 
● ls – List directory contents
● file – Determine file type
● less – View file contents

if you don't get my point please read my prevoius article in linux commanding :



if you already read it let's start learning some higher level commands than previous...


More Fun With ls

The ls command is probably the most used command, and for good reason. With it, we
can see directory contents and determine a variety of important file and directory attributes.As we have seen, we can simply enter ls to see a list of files and subdirectories contained in the current working directory:
today specially we exploring the power of ls command..
so , what we can do with this command..approx..we cover mmost of command in this article..along with this i make an video of this article..but before let's understand what are those command..

1.to see a list of files and subdirectories contained in the current working directory:

command ubuntu@ubuntu:~$ ls 





2.Besides the current working directory, we can specify the directory to list, like so:

command : ubuntu@ubuntu:~$ ls  /usr






3. even specify multiple directories.

command : ubuntu@ubuntu:~$ ls ~ /usr





In this example we will list both the user's home directory

symbolized by the “~” character and the /usr directory

4. change the format of the output to reveal more detail:

command : ubuntu@ubuntu:/usr$ ls -l



actually we will talk about this command in detail in later article..actually it's about security and permission of the directory file..mean which user can delete,edit or share this file ..to other..i am here explainning about the  commands meaning..
here is an copy of one result...for better understanding..

             drwxr-xr-x  2 root root 69632 Nov  6 07:22 bin

  • Next 3 words (drwxr-xr-x) are permissions for the file or directory.
  • The next file is the number(2) of blocks (don't worry too much about this).
  • The next field is the owner(root) of the file or directory .
  • The next field is the group(root) the file or directory belongs to .
  • Following this is the file size(69632 byte).
  • Next up is the file modification time(Nov 6 07:22).
  • Finally we have the actual name of the file(bin) or directory.

5. We ran ls with a command line argument ( /etc ).this will explore all the detail of the directory /etc:

command : ubuntu@ubuntu:/$ ls -l /etc



these are the some examples of the 'ls' commands..but intead of this we are now discussing about these commands meaning in a understandable manner...with some more arguments in 'ls' commands..let start...

Options And Arguments :

This brings us to a very important point about how most commands work. Commands are often followed by one or more options that modify their behavior, and further, by one or more arguments, the items upon which the command acts. So most commands look kind
of like this:

command -options arguments 

NOTE :


Most commands use options consisting of a single character preceded by a dash, for example,
“-l”, but many commands, including those from the GNU Project, also support 

long options, consisting of a word preceded by two dashes. Also,



 many commands allow 

multiple short options to be strung together. In this example, the ls command is given 

two options, the “l” option to produce long format output, and the “t” option to sort the

result by the file's modification time.


command :ubuntu@ubuntu:/$ ls -lt



We'll add the long option “--reverse” to reverse the order of the sort:

command ubuntu@ubuntu:/$ ls -lt --reverse


NOTE :
FILE NAME AND COMMANDS BOTH ARE CASE SENSTIVE IN THE LINUX TERMINAL

The ls command has a large number of possible options. The most common are listed
i will explain all these commands in video..first learn all these very carefully...and practice as possible as...

  • -a   or  --all  :

 List all files, even those with names that begin

with a period, which are normally not listed

(i.e., hidden). 


command :ls -a



   
NOTE : 
IN LINUX AS WELL AS IN ANDROID(IT IS ALSO AN LINUX DISTRIBUTION)
you can hide your file by applying '.' before the file name. 

  •  -A or  --almost-all :

Like the -a option above except it does not

list . (current directory) and .. (parent

directory).

command : ls -A


command : ls -l -A


  •  -d  or --directory :

Ordinarily, if a directory is specified, ls will

list the contents of the directory, not the

directory itself. Use this option in conjunction

with the -l option to see details about the
directory rather than its contents.

command : ls  -l -d



  •  -F or --classify :

This option will append an indicator character

to the end of each listed name. For example, a

“/” if the name is a directory.


command : ls -l -F


compare the result with usually simple command ls and ls -F.

  • -h or --human-readable :

In long format listings, display file sizes in

human readable format rather than in bytes.



command : ls -l -h


actually in try to explain my point.if you don't get it useful leave it.these are only for your information.


A Longer Look At Long Format

As we saw before, the “-l” option causes ls to display its results in long format. This format contains a great deal of useful information. Here is the Examples directory from an Ubuntu system:

command : ls -l

-rw-r--r-- 1 root root 3576296 2007-04-03 11:05 Experienceubuntu.ogg
-rw-r--r-- 1 root root 1186219 2007-04-03 11:05 kubuntu-leaflet.png
-rw-r--r-- 1 root root 47584 2007-04-03 11:05 logo-Edubuntu.png
-rw-r--r-- 1 root root 44355 2007-04-03 11:05 logo-Kubuntu.png
-rw-r--r-- 1 root root 34391 2007-04-03 11:05 logo-Ubuntu.png
-rw-r--r-- 1 root root 32059 2007-04-03 11:05 oo-cd-cover.odf
-rw-r--r-- 1 root root 159744 2007-04-03 11:05 oo-derivatives.doc
-rw-r--r-- 1 root root 27837 2007-04-03 11:05 oo-maxwell.odt
-rw-r--r-- 1 root root 98816 2007-04-03 11:05 oo-trig.xls
-rw-r--r-- 1 root root 453764 2007-04-03 11:05 oo-welcome.odt
-rw-r--r-- 1 root root 358374 2007-04-03 11:05 ubuntu Sax.ogg

EXPLANATION:

-rw-r--r-- :

Access rights to the file. The first character indicates the
type of file. Among the different types, a leading dash
means a regular file, while a “d” indicates a directory.
The next three characters are the access rights for the
file's owner, the next three are for members of the file's
group, and the final three are for everyone else. The full
meaning of this is discussed in Chapter 9 – Permissions.
1 File's number of hard links. See the discussion of links
later in this chapter.

root :

The username of the file's owner.

root :

The name of the group which owns the file.

32059 :

Size of the file in bytes.

2007-04-03 11:05 :

 Date and time of the file's last modification.

oo-cd-cover.odf :

 Name of the file.


tha's it for the 'ls' command.now learn next topic of today article..'file' command.

Determining A File's Type With file

As we explore the system it will be useful to know what files contain. To do this we will use the file command to determine a file's type. As we discussed earlier, filenames in Linux are not required to reflect a file's contents. While a filename like “picture.jpg” would normally be expected to contain a JPEG compressed image, it is not required to in Linux. We can invoke the file command this way:

file filename


When invoked, the file command will print a brief description of the file's contents.
For example:

command : file picture.jpg


There are many kinds of files. In fact, one of the common ideas in Unix-like operating
systems such as Linux is that “everything is a file.” As we proceed with our lessons, we
will see just how true that statement is.
While many of the files on your system are familiar, for example MP3 and JPEG, there
are many kinds that are a little less obvious and a few that are quite strange.

Viewing File Contents With less

The less command is a program to view text files. Throughout our Linux system, there
are many files that contain human-readable text. The less program provides a convenient
way to examine them.

                     What Is “Text”?

There are many ways to represent information on a computer. All methods involve defining a relationship between the information and some numbers that will be used to represent it. Computers, after all, only understand numbers and all data is converted to numeric representation. Some of these representation systems are very complex (such as compressed video files), while others are rather simple. One of the earliest and simplest is called ASCII text. ASCII (pronounced "As-Key") is short for American Standard Code for Information Interchange. This is a simple encoding scheme that was first used on Teletype machines to map keyboard characters to numbers.Text is a simple one-to-one mapping of characters to numbers. It is very compact.Fifty characters of text translates to fifty bytes of data. It is important to understand that text only contains a simple mapping of characters to numbers. It is not
the same as a word processor document such as one created by Microsoft Word or OpenOffice.org Writer. Those files, in contrast to simple ASCII text, contain many non-text elements that are used to describe its structure and formatting.Plain ASCII text files contain only the characters themselves and a few rudimentary control codes like tabs, carriage returns and line feeds.Throughout a Linux system, many files are stored in text format and there aremany Linux tools that work with text files. Even Windows recognizes the importance of this format. The well-known NOTEPAD.EXE program is an editor for plain ASCII text files.                                     

Why would we want to examine text files? Because many of the files that contain system
settings (called configuration files) are stored in this format, and being able to read them
gives us insight about how the system works. In addition, many of the actual programs
that the system uses (called scripts) are stored in this format. In later chapters, we will
learn how to edit text files in order to modify systems settings and write our own scripts,
but for now we will just look at their contents.

The less command is used like this:

less filename

Once started, the less program allows you to scroll forward and backward through a
text file. For example, to examine the file that defines all the system's user accounts, enter

the following command:

command : less /etc/passwd

Once the less program starts, we can view the contents of the file. If the file is longer
than one page, we can scroll up and down. To exit less, press the “q” key.

below lists the most common keyboard commands used by less.



Command                     Action

Page Up or b           Scroll back one page

Page Down or space     Scroll forward one page

Up Arrow               Scroll up one line

Down Arrow             Scroll down one line

G                      Move to the end of the text file

1G or g                Move to the beginning of the text file

/characters            Search forward to the next occurrence of                              characters

n                      Search for the next occurrence of the                                  previous search

h                      Display help screen

q                      Quit less


please refer every commands i describe above and try to practice in your machine that will give you an exellent result in learning the command like .i hope you enjoyed this article.
please share your view in comment box.and suggest me other commonds which i just forget to mention here..than you for visiting...


 we will post video in next article with an practice tour which will practice all your commands learn in navigation list..


read my next article on commanding ...
                        

until next article this is :

ZEROCOOL
SIGNOUT

Popular Posts