Skip to main content

How to: a beginner’s Guide to the Linux command line

Do you remember the command line as an outdated leftover from the past or an old-fashioned and way of interacting with a computer? Think again. In Linux it is the flexible and efficient way to perform tasks. For example, all .tmp files in a directory (and its subdirectories) are looking for and then delete a multi-stage process, when graphical user interface can be performed, but a matter of a few seconds, if from the command line is executed.

How to: a beginner's Guide to the Linux command lineHow to: a beginner’s Guide to the Linux command line

In this article, we discuss the basics of the Linux command line including directory navigation and search, and file/directory operations. Once you have mastered this, you can check part II of the Guide, which is to discuss a level of deeper, file metadata, permissions and timestamps.

How to: a beginner’s Guide to the Linux command line

Note: this feature was originally published on 19.06.2014. We have met, because it is now as relevant as it was before, if you learn the ropes of Linux. Part of our #ThrowbackThursday initiative.

1. What is a home directory on Linux?

Linux is a multiuser operating system, which means that more than one user at the same time the operating system can access. To make things easy, a directory, each user is assigned to where to store their personal files. This directory is called the home directory of the user.

Home directories, see user folder. For example, my home directory is / home / art theory . Please keep in mind that a user’s home directory has the same name as your login name. If you are a Windows user, you can a Linux home directory present, like a specific directory of the user usually inside C:Documents and settings or C:Users .

Users have complete control over their home directory and all its subdirectories. This means that they can freely operations such as creating and deleting files/directories, programs install and more in your home directory.

2. Check how this directory?

When you open a command-line shell under Linux, you start with your home directory. This is your present working directory, that changes when you switch to a different directory. pwd command to verify your present working directory at any point of time use, the full path.

Here is an example:linux tutorial command line

pwd command, shown in the illustration above, indicates that the user is currently in image directory, the art theory in the directory, which, in turn, a subdirectory of the directory is home . in this case, [email protected]:~/Pictures$ is the command prompt.

3. How can I change directories?

Navigate using command “cd ” the Linux file system. This command requires either a directory name or the full path, depending on, where the directory exists.

For example, if is/home/Himanshu/images , and you want to change your current working directory, , , home, Himanshu, pictures, holiday then simply run the command: cd holiday . In this case, the command line shell for the holidays will look directory in pictures . Also known as a relative path is a path relative to the current working directory.

But in the event that you want to change / home/TechSpot you must run the command: cd/home/TechSpot . The full path beginning with a forward slash (/), also known as its absolute path is a directory. To quickly change to the previous directory in the tree, run: cd… , or if you change work you to the previous run directory CD

4. Displaying directory contents?

Use command ls , to the contents of a directory list. When running the command without any arguments, it shows the content of the present working directory.

To display the content from any other directory, you can specify either the name or the full path (if it is a subdirectory) (if there no subdirectory) as an argument to the ls command. If you watch closely, the issue of is colour coded for ls command. These different colors represent different types of files, making it easy to identify them visually. Some of the basic colors you should know are: Green blue (directories), white (text files), Red (archive), cyan (“left”), (executable files) and Rosa (pictures).

5. How to such as: view the contents of a file?

Use cat command to display the contents of a file. This command expects a file name as an argument. As you can see in the screenshot below, the command cat to display the contents of the file arg.c . However, there is a constraint. If the file is large, the issue could be too large to accommodate screen for the command line shell

In this case, you can use the fewer command cat command together with the : [filename] cat | less . | symbol stands for a tube, which the output of the command cat , less directs command, which in turn makes it possible that you scroll to navigate through the contents of the file using the arrow keys on your keyboard up and down. To exit the display mode button Q .

6. known as: create a new file?

Use contact command to create a new file. The command requires a filename as an argument. For example, create a file called test.log in the present directory, just run the command: test.log touch.

To create a new file in a location other than the current working directory, use the absolute path. For example touch / home/himanshu/practice/test.log.

Tip: write something in a newly created file, use a command line editor such as VI or VIM.

7. known as: Rename/copy/delete a file?

Use MV command to rename a file. For example to log.txt , new_log.txt rename, run the command: MV log.txt new_log.txt . As always, if the file is not in the current directory, use the absolute path.

Can you use also the MV command, move a file from one place to another. This is the equivalent of a cut paste operation via GUI. For example, to / home / art theory log.txt (today in the current directory) to move, run the command: MV log.txt/Home/kunsttheoretische. cp

A file from one directory to a different, use command copy. As the command MV , , cp requires a source and a destination. For example, cp log.txt/Home/kunsttheoretische would create a copy of the log.txt (with the same name) in the directory / home / art theory .

A  file to remove use command RM . This command expects a file name as an argument. [Forexample RM log.txt the text file to remove, if any, in the current directory, while RM / home/himanshu/practice/log.txt deletes the text file in the directory practice

Directories, use the r command-line option with the command RM . For example, RM – R/home/Himanshu/practice / the practice would delete directory with all subdirectories and files.

8. How to search for files?

search for files in a particular directory search command using . The command requires a directory path and file name as an argument. To search for a file called inheritance.cpp in / home/Himanshu / directory, for example, the command find as follows:

I used sudo in the search command above to eliminate specific permission error. You can skip it. If a path is not specified, the find command searches in the present. Wildcards with the search command can use to make the most out of it. For example, if you are presenting all .c files in the / home/Himanshu/practice directory, use to find the command , as shown below. The “*” character is a placeholder that can represent any number of characters. For example, tech can * represent tech, TechSpot, and report.linux tutorial command line

9. As you search for text in files?

Search for text in files, use grep command. The command is a keyword and a file name as an argument and lines that contain the keyword. All lines in the file such as the search for grep command /home/himanshu/practice/wazi/gdb/test.c, which contain the PTR keyword , as follows:

use-n command-line option in the event that you show grep line numbers want to issue.

Tip: search for a keyword in all files in the current directory, use the * wildcard characters as the file name.

Please note, that find in contrast to the command, the command grep not by default search subdirectories. But you can enable this feature by using the r command-line option when you run the command grep .

10. What is the auto-complete feature?

Feel while work at the Linux command line, long can enter paths and file names, such as a load. Use the tab key to auto-complete easily this long names and paths. For example, to write / at home, you can simply write / ho and click on tab. The name for you will automatically complete the command-line shell.

In the example above it was to guess just for the shell, home to the name , since there were no other similar candidates in the / directory. But in case similar name to complete the shell when the car encounters, these names are displayed and you need to know a few more letters for the shell of the correct name.

The shell shows all names that can use it for auto-completion. Would, for example write TechSpot, then are you have to at least give c to resolve the ambiguity. Once done, you can tab button again AutoComplete the name beat.

11. What is root?

Root is the only user that has control over the entire system. It is capable, what normal users don’t add such as changing the ownership of files, or remove files from system directories, and much more. As you can imagine, the root account usually by only system administrators is used.

Who represent top level directory on a Linux system, by slash ( / ), is known as the root directory. It is the same directory that contains the home directory specific directories containing other users. But be sure not to confuse / with the root user’s home directory, which is located under / to root with the name .

12. What are man pages?

For more information about Linux commands, you can head over their respective man (or manually) pages that are preinstalled with Linux. A one-page, only command “run man ” followed by the name of open command. For example, RM run man to open the man page for the command RM . In this way you will find lots of useful information about Linux commands

We’ve scratched the surface barely here, such as the Linux command line has much to offer. Practice and master each command in this article describes. If you stuck somewhere, make a comment, or head over to our & software applications leave Forum. As we go deeper file metadata, permissions, timestamps, as well as some new tools such as discount, VIM and much to discuss more.

Source: http://www.techspot.com


Find more at: Tech Cuber

Comments

Popular posts from this blog

Bass Fishing Connection

๐Ÿ‘ Product: Bass Fishing Connection ๐Ÿ‘‰ Click right here to get Bass Fishing Connection at discounted worth whilst it is nonetheless to be had… Product Description: Boatlanes Downloadable Gps Way Points Marking Actual Boat-running Lanes On Texas’ Premier Bass Fishing Lakes: Lake Fork, Sam Rayburn, T-bend. Selling Like Crazy! 50% To Affiliates Great Conversion Rate Exceptional Customer Service/product Support! All orders are secure by means of SSL encryption – the best business usual for on-line safety from relied on distributors. ๐Ÿ‘‰ Click right here to get Bass Fishing Connection at discounted worth whilst it is nonetheless to be had… Find more at: Tech Cuber

Health PLR Articles | Health Private Label Rights

๐Ÿ‘ Product: Health PLR Articles | Health Private Label Rights ๐Ÿ‘‰ Click right here to get Health PLR Articles | Health Private Label Rights at discounted worth whilst it is nonetheless to be had… Product Description: A Total Of 889 Health Plr Articles For 5 Hot Health Niche Market Categories That Are Currently High On Demand. Market Niches Include Health Nutrition, Health Food, Health Diet, Natural Health And Health Supplement. A Must-have For All Online Marketers!!! All orders are safe via SSL encryption – the absolute best trade usual for on-line safety from relied on distributors. ๐Ÿ‘‰ Click right here to get Health PLR Articles | Health Private Label Rights at discounted worth whilst it is nonetheless to be had… Find more at: Tech Cuber

RV Drivesmart

๐Ÿ‘ Product: RV Drivesmart ๐Ÿ‘‰ Click right here to get RV Drivesmart at discounted value whilst it is nonetheless to be had… Product Description: Drive Your Motorhome Like A Pro Is A Complete Guide To Professional Driving Techniques For Beginners To Experienced Drivers. All orders are secure by way of SSL encryption – the perfect business same old for on-line safety from relied on distributors. ๐Ÿ‘‰ Click right here to get RV Drivesmart at discounted value whilst it is nonetheless to be had… Find more at: Tech Cuber