Now remaining are just 2 operations .Copying and moving files and folders.You can copy a file using cp command
Inorder to copy a file to a destination we can use cp command.usage is listed as follows:
cp <file to copy > <destination>
Moving Files or folders with mv command.
mv <source file > <destination>
Now you can handle your files and folders easily.
Showing posts with label Terminal. Show all posts
Showing posts with label Terminal. Show all posts
Wednesday, 29 February 2012
Thursday, 23 February 2012
Handling Folders and Files with Linux command Line[part2]
In the previous part I just explained 3 commands that will help you to navigate through files and folders in your system.In this section let us discuss how to perform some actions like create, rename, remove folders using command line.
Creating a folder using the command:
The command used to create a folder is mkdir .Open up the terminal and type :
mkdir myfolder
A new folder named myfolder will be there in your home directory.You can make folders anywhere in your system.But you must mention the directory address for your folder with folder name otherwise the folder will be created in the current directory.
Eg: to make a folder in the directory /tmp use the following command.
mkdir /tmp/myfolder
Extra note : Normally your system will not display any message after creation of the folder. If you add the parameter -v to the mkdir command you will get a message after the creation of the folder (eg: mkdir myfolder -v)
Removing a file or folder
The Linux kernel consider folder and file as same .You can remove any file or folder using the command rm .
the usage of the command is rm [option] <file> .
Here are the important options you might use.
-f (forcefully removes file with no prompting)
-v (Explains what is being done)
-r (Removes files recursively in a directory.It is used when the folder contains subfolders.)
I just mentioned the syntax above. But you need just a single command to remove a folder that is
rm -rf /tmp/myfolder
here '-rf' is the option with the command which says that files will be removed recursively and forcefully. And /tmp/myfolder will be the folder we want to delete.
Creating a folder using the command:
The command used to create a folder is mkdir .Open up the terminal and type :
mkdir myfolder
A new folder named myfolder will be there in your home directory.You can make folders anywhere in your system.But you must mention the directory address for your folder with folder name otherwise the folder will be created in the current directory.
Eg: to make a folder in the directory /tmp use the following command.
mkdir /tmp/myfolder
Extra note : Normally your system will not display any message after creation of the folder. If you add the parameter -v to the mkdir command you will get a message after the creation of the folder (eg: mkdir myfolder -v)
Removing a file or folder
The Linux kernel consider folder and file as same .You can remove any file or folder using the command rm .
the usage of the command is rm [option] <file> .
Here are the important options you might use.
-f (forcefully removes file with no prompting)
-v (Explains what is being done)
-r (Removes files recursively in a directory.It is used when the folder contains subfolders.)
I just mentioned the syntax above. But you need just a single command to remove a folder that is
rm -rf /tmp/myfolder
here '-rf' is the option with the command which says that files will be removed recursively and forcefully. And /tmp/myfolder will be the folder we want to delete.
Labels:
Basics,
Terminal,
Terminal Dictionary
Wednesday, 8 February 2012
Handling Folders and Files with Linux command Line[part1]
As
we know Linux command Line is the powerful tool for a user. First of all let us discuss about 3 basic commands which helps you to manage files and folders.
- pwd
- ls
- cd
pwd
:
This command prints the
present working directory. That is if you want to know actual
location where you are standing in your terminal section ,just type
pwd . It makes your navigation better.
ls :
The
ls command is used to list the files and folders in the current
directory .It is similar to the 'dir' command in Windows. It is
important to mention about some parameters those are used along with
ls to make this mapping efficient .
1.
ls -a
The
above command will list all the files and folders including the
hidden
files.
2. ls -r
This
command will list the contents in reverse order.
3. ls *.txt
This
will list all the files of type .txt .You can change the extension
say .jpeg
for picture type files.
cd
:
The simple command which is used to navigate to another directory
expanded as change directory. The syntax is cd <directory>
eg:
cd /usr/bin will move the current directory to /usr/bin.
Note : You can navigate to
the previous directory by the command 'cd ..'Wednesday, 14 December 2011
Searching strings with grep command
Let me discuss a situation- I have
saved all of my contacts information as separate files and put it in
a folder called contacts. I have to find the file which contain the
name Mr. John. I get started with opening each files in my text
editor and ctr+f to find john..it was too difficult since I have
about 300 files to search. But working a little smart I found john in
2 minutes..How ? The grep command .
Grep is a command-line text-search utility originally written for Unix. The name comes from the ed command g/re/p (global / regular expression / print). The grep command searches the given file for lines containing a match to the given strings or words. grep displays the matching lines by default.
How to use grep command :
1.Searching for a string in a file
Grep is a command-line text-search utility originally written for Unix. The name comes from the ed command g/re/p (global / regular expression / print). The grep command searches the given file for lines containing a match to the given strings or words. grep displays the matching lines by default.
How to use grep command :
1.Searching for a string in a file
$ grep train vehicles.txt
the above usage will print all the
lines containing the text train from vehicles.txt
2 .Searching in multiple files
of same type :
$ grep train *.txt
the above command will print all the
lines with text 'train' from all the text files in that folder
3. Searching by ignoring case
sensitivity (with parameter -i)
$ grep -i train vehicles.txt
the above command will search all the
'train' sequences wihtout matching the cases.
4 . Word search
$ grep -w train vehicles.txt
and train do not not match) may be accomplished with the -w option flag
5. Count lines when words are matched
$ grep -c 'word' /directory
grep can count the number of times that the pattern has been matched for each file using -c (count) option.
6.Search recursively in an entire directory
$ grep -r 'word' /directory
You can search recursively i.e. read
all files under each directory for a string .
Labels:
Terminal,
Terminal Dictionary
Friday, 25 November 2011
Have Fun with Command Line Browser In Linux
I would like to mention about command
line again. These days I was trying something different in my
terminal .something smells good and useful .what was that ?Simply
access the web pages in command line. A Google searched gave me
solution .It is somewhat a special experience ,especially for a Geek.
Imagine a situation like this.. if your GUI get crashes and you have
only the command line access and u need to check one of your
important mails ,no other ways .....Don't Worry, A software called
links2 comes to help you .
Links2 is a web browser which is
based on 'links' and can be run in two modes. It will display web
pages only in text when run in console mode and renders images in a
variety of graphics formats when run in graphics mode from within a X
window system. Without going to more technical let me explain what to
do :
* Install Links2 to in your system
:
steps are simple . Connect to Internet and type following command
to the terminal
$ sudo apt-get install links2
$ sudo apt-get install links2
The browser is designed to run in
console mode. But it can be run in graphics mode too..the important
feature is the speed. It render the Web-pages very fast .
* How to start and browse with
links2 ?
Open terminal and type following
command:
$ links2
www.google.com
replace www.google.com
with your site..
* Start links2 in graphics mode
Open terminal and type following
command:
$ links2 -g
www.google.com
* Shortcuts used in links2 :
- '\' - toggle between viewing the web page and its source code.
- '/' - used to search for a word or term in the website that
is displayed.
- [Esc]key - Shows a menu at the top of the browser from which
you can also make choices.
- '=' - Provides further information about the web page such as
its size, the web server serving the web page and its url.
- '|' - Pipe displays the header information.
- '<-' - left arrow will take you to the previous view. '->'
- right arrow will take you forward to the latest view.
- [Page up]and[Page down]- these keys can be used to navigate
through the web page one page at a time. But you can also use[Space
bar]and 'b' key combination for the same.
- 'g' - will pop-up a dialog box where you can enter the url of
the website you want to view. To open this dialog box with the url
of the current page already entered, press 'G'.
- Move the mouse pointer over an image and press 'i' to see
only the image.
Geeks please note :
You can find
a hidden folder .links2/ in your home folder with configuration files
.A file named links2.cfg contains all configurations.
Screen shots :
Subscribe to:
Posts (Atom)