You are on page 1of 6

Section #2

*** Login screens & TTY Consoles ***

1. Graphical
Start your machine normally, you will get a list of the users on your
operating system, click any one of them, you’ll be then asked to enter
the password.

2. TTY
A “Text-based” system where you only use the keyboard to enter
commands .. No graphical interfaces, No mouse, nothing ... Just you and the
keyboard.

5 TTY consoles are available


TTY2 --> right ctrl + f2
TTY3 --> right ctrl + f3
TTY4 --> right ctrl + f4
TTY5 --> right ctrl + f5
TTY6 --> right ctrl + f6

--> Return back to the graphical interface by hitting the following keys
Right ctrl + f1

After getting on a TTY you’ll be asked to enter a “user name” and


“password” ... Notice that nothing will appear when you’re entering your
password .. Just keep entering it and hit Enter at the end.

Log into different TTYs and then use the command “ who” to know
which users are logged on which TTYs

This means
User “ahmad” logged into the graphical interface ( :0 )
User “ahmad” logged into tty2
User “root” logged into tty3

--> to log out either write the command “exit” or just hit
Left ctrl + D
*** Relative & Absolute Path ***

In windows OS each partition (Like C & D & E ....) is the root of all the
files and folders (directories) lying under it. There is NO one root gathering
all the partitions together.

With Linux, Every file and every folder is a descendant of what’s called
the root directory denoted by a forward slash “/”

Navigating your file system

1. Relative Path
Assuming you’re standing at folder “ahmad” and wants to get
into folder “folder_x”
Use the cd command as follow
[ahmad@localhost ~]$ cd folder_x
To move back into folder “ahmad”, use the cd command
and place “..” after it

[ahmad@localhost ~]$ cd ..
This is just like hitting the back button when working in a
graphical interface

Put simple, if you want to get into a folder that is directly in the
next level to the folder your standing in use the “cd” command with
the folder name.

Example ( You’re current location is folder “ahmed” )


--> To move into folder “folder_y”
[ahmad@localhost ~]$ cd folder_y
--> To move into folder “folder_x”
[ahmad@localhost ~]$ cd folder_x
--> To move into the root directory (Move a step back)
[ahmad@localhost ~]$ cd ..

Example ( You’re current location is folder “folder_x” and you


want to move into folder “rh” )

Step #1: move a step back to folder “ahmad”


[ahmad@localhost folder_x]$ cd ..
Step #2: move a step back to folder “home”
[ahmad@localhost ~]$ cd ..
Step #3: move a step back to the root directory “/”
[ahmad@localhost home]$ cd ..
Step #4: move into the “opt” folder
[ahmad@localhost /]$ cd opt
Step #5: move a step back to the root directory “/”
[ahmad@localhost opt]$ cd rh

All these steps can be combined into a single


command as follows:
[ahmad@localhost folder_x]$ cd ../../../opt/rh

This is what we call a “relative path”, the keyword here is


“relative” ... You move into a certain folder relatively to your
current location.
2. Absolute path
With absolute path, you don’t think in term of your current
location, instead you start from the root directory “/” and
keep moving down until you reach your destination.

Example ( You’re current location is folder “folder_x” and


you want to move into folder “rh” )

* Start with “/” and on every folder you cross, write its
name... Separate the folder names with a “/”

--> Starting from the root directory “/”


Folders you’ll move across are opt & rh
So the final path should be as follows:

/opt/rh
[ahmad@localhost folder_x]$ cd /opt/rh

NOTE: this has nothing to do with your current location

*** Files Viewing and Editing ***

1. Create a file using the command “touch”

touch file_path
Where file_path is either the relative path or the absolute path

# Create a file named “file_1” under your current location


[ahmad@localhost ~]$ touch file_1

# Assuming your current location is “rh” and you want to


# create a file named “file_1” under the folder “ahmad”
# Here we will try using the two approaches, relative and
# absolute path
[ahmad@localhost ~]$ touch ../../home/ahmad/file_1
[ahmad@localhost ~]$ touch /home/ahmad/file_1

* Note the file name is placed at the end after the path itself
# Suppose you want to create multiple files having a common
# sub-name like for example (f1, f2,f3, f4, f5, f6)
# This can be done as follows
[ahmad@localhost ~]$ touch f{1..6}

2. Remove a file using the command “rm”

rm file_path

# remove a file named “file_1” under your current location


[ahmad@localhost ~]$ rm file_1

# Assuming your current location is “rh” and you want to


# remove a file named “file_1” under the folder “ahmad”
# Here we will try using the two approaches, relative and
# absolute path
[ahmad@localhost ~]$ rm ../../home/ahmad/file_1
[ahmad@localhost ~]$ rm /home/ahmad/file_1

* Note the file name is placed at the end after the path itself

# Suppose you want to remove multiple files having a common


# sub-name like for example (f1, f2,f3, f4, f5, f6)
# This can be done as follows
[ahmad@localhost ~]$ rm f*

This simply means: remove any files starting with the letter “f"

--> By default the OS gives you a message asking you to


confirm if you want to delete this message .. To get rid of this
message, Use the command as follows
[ahmad@localhost ~]$ rm -f f*
-f is short for “force” which means (remove without showing
any confirmation messages)

3. Copy a file using the command “cp”

cp src_file_path dest_file_path
# Assuming being in “folder_x”, where we have a file named
# “my_file” and we want to copy this file into “folder_y”
[ahmad@localhost ~]$ cp file_1 ../folder_y
Notice here we used “relative paths” for both the source
and the destination
- “file_1” is directly below “folder_x” so we directly wrote its
name
- ../folder_y is clearly a relative path.

You might also like