Introduction to Linux Basics - LinuxHunt
186
 

Introduction to Linux Basics

Introduction to Linux Basics

Linux is a free, open-source operating system. Linux has been under active development since 1991. It has evolved to be versatile and is used all over the world, from web servers to cellphones. However, newcomers to Linux may find it difficult to approach the structure of an unfamiliar operating system.This guide gently introduces key terminal skills and equips newcomers to learn more about Linux.

Must Read :- “Linux looks boring. But it not “  Try Linux and see how  it is so interesting itself .

.

Navigation

Linux filesystems are based on a directory

tree. This means that you can create directories (or “folders”) inside other directories, and files can exist in any directory.

Linux all commands are case sensitive in nature .

To see what directory you are currently

active in:

pwd 

This stands for “print working directory”, and will print the path to your current directory. The output can look similar to this:

/home/backup                        

This means that your current active directory is backup, which is inside home, which lives in the root directory, /.

To see other files and directories that exist in your current working directory:

ls 

This will give you a list of names of

files and directories. To navigate into a directory, use its name:

cd <name of directory>

This will change your new current worki

ng directory to the directory you specified. You can see this with pwd.

Additionally, you can specify .. to change to the directory one level up in your path. To get back to your original directory:

cd .. 

We can also create new directories in our current working directory. For example, to create a new directory called bar:

mkdir bar

Then we can

cd

into bar if we want. We can also delete bar if we no longer find it useful:

rm -d barrm –d 

will only delete empty directories.

File Manipulation

Files cannot be used with

cd 

(it stands for “change directory”).

Instead, we can view files. Say we have a file backup in our current directory:

cat backup 

This will print out the entire contents of backup to the terminal.

With long files, this is impractical and unreadable. To paginate the output:

less backup 

This will also print the contents of backup, bu

t o

ne terminal page at a time, beginning at the start of the file.

Use the spacebar to advance a page, or the arrow keys to go up and down one line at a time. Press q to quit out of less.

To create a new file called DBbackup:

touch DBbackup 

This creates an empty file with the name DBbackup in your current working directory. The contents of this file are empty.

If we decide DBbackup isn’t such a good name after all, we can rename DBbackup to tsp:

mv DBbackup tspmv 

stands for “move” and it can move a file or directo

ry from one place to another.

By specifying the original file, we can “move” it to a new location in the current working directory, thereby renaming it.

It is also possible to copy a file to a new location. If we want to bring back DBbackup, but keep tsptoo:

cp tsp DBbackup 

Just as you guessed,

cp 

is short for “copy”. By copying tsp to a new file called

DBbackup, we have replicated the original file in a new file with a different name.

However, what good is a file if it contains nothing

? To edit files, a file editor is necessary.

There are many options for file editors, all created by professionals for daily use. Such editors include vim, emacs, nano, and pico.

nano is a perfectly suitable option for beginners. It is easy and simple to use, with no bells or whistles to confuse the average user.

To edit text into DBbackup:

nano DBbackup 

This will open up a space where you can immediately start typing to edit DBbackup.

To save the written text, press

ctrl-X 

then y. This returns you to the shell with a newly saved DBbackup file.

Now DBbackup has some text to view when using

cat

or

less

.

Finally, to delete the e

mpty tsp:

rm tsp

Unlike directories, files are deleted whether they contain content or not.

No Comments

Post A Comment

Get notified automatically by email when there is new content!
For Questions or Comments, Contact us: editor @ linuxhunt.com

You have successfully subscribed to the newsletter

There was an error while trying to send your request. Please try again.

LinuxHunt will use the information you provide on this form to be in touch with you and to provide updates.