SlideShare a Scribd company logo
Laboratory Activity 1
Name: __________________________________ Date: _____________
Unix Basic Commands
1.0 Unix / Linux Command Line Interface (CLI) Basics – Basic Commands
This section of the course provides a discussion and hands-on guide on the basic CLI commands in Unix/Linux. The
basic CLI commands are: how to log-in, log-out, interpreting the command prompt, how to enter commands, basic file
commands and management, and simple file permission. The objectives of this section are:
• Familiarize the students on how to gain access to a Unix/Linux server.
• Familiarize the students on what is the prompt and how to enter commands.
• Familiarize the students on file identifiers and, relative and absolute file names.
• Familiarize the students on basic file commands and management.
1.1. Logging In
To access a Unix/Linux server, a Telnet or SSH client software can be used to connect to the server. Most operating
system today has some form of this software like “putty.exe”. A login prompt for a Unix server can look like:
Login: <username>
Password:
Before you try to log-in to a Unix server, ask your instructor for a user account, and the IP address or server name
where your account is valid. After acquiring the user account and the server you are assigned to, accomplish the
following:
Step 1 On your Windows operating system, use an ssh client program to connect to the Unix server. Using the
“putty” client program, enter the IP address or name of the Linux server in the “Host Name” text box and
click the “Open” button.
1
Step 2 At the login prompt, type your assigned username and password.
2a. Were you able to login? How were you able to login?
_________________________________________________________________________
_________________________________________________________________________
2b. Did you have a user account when you logged-in?
_________________________________________________________________________
_________________________________________________________________________
2c. What is the IP address or server name of the Unix server you logged into?
_________________________________________________________________________
_________________________________________________________________________
1.2. The Command Prompt
After you have logged-in, notice that a prompt will appear on the screen. A prompt is an interface that allows user to
input commands. Different shells use different faces of prompts (shells will be tackled later in the course). In this
server, you will be greeted with:
Notice the different parts of your prompt. For the example prompt, it has displayed the username, current directory you
are in, the computer name and the prompt sign.
Step 3 Write down the prompt on your screen.
_________________________________________________________________________
_________________________________________________________________________
3a. Is your username displayed on the prompt? What is your username?
_________________________________________________________________________
_________________________________________________________________________
3b. Is a computer name displayed on the prompt? What is the computer name?
_________________________________________________________________________
_________________________________________________________________________
2
3c. What is the prompt sign on your screen?
_________________________________________________________________________
_________________________________________________________________________
1.3. Entering Commands
Commands can be entered to the Unix server via the command prompt. This is usually done by typing a series of
characters after the prompt sign. A usual format in entering commands is:
[dwight@netopsy1 greg]$ command <options> <argument>
Options for the command are switches that tell a command to do something differently. Arguments are information
sometimes needed by the command to be able to execute properly. Most of the time, options and arguments are not
needed in a command.
There are also commands wherein you do not need to type anything. These commands are: ctrl-c, ctrl-d, ctrl-s, and
ctrl-d. The table below gives a short description.
Step 4 On the command prompt, type “man –S 1 pwd” and press enter. This command will be tackled later in the
course, for now just accept it.
4a. What is the option in the command?
_________________________________________________________________________
_________________________________________________________________________
4b. What is the argument in the command?
_________________________________________________________________________
_________________________________________________________________________
4c. Press “q” to exit the command.
_________________________________________________________________________
_________________________________________________________________________
Step 5 On the command prompt, type “top” and press enter.
5a. Press the control and “c” key at the same time. What happened? Did it have the same effect as pressing “q”?
Why”
_________________________________________________________________________
_________________________________________________________________________
3
Step 6 On the command prompt, type ”man chmod” and press enter.
6a. Press the spacebar. Did the screen scroll up?
_________________________________________________________________________
_________________________________________________________________________
6b. Press the control and “s” key at the same time and then press the spacebar. Did the screen scroll up? Why?
_________________________________________________________________________
_________________________________________________________________________
6c. This time press the control and “q” key at the same time. What happened?
________________________________________________________________________
_________________________________________________________________________
6d. What does the command “ctrl-s” and “ctrl-q” do?
________________________________________________________________________
_________________________________________________________________________
1.4. Changing Password
One of the first things you must do on your user account is to change your password. Password ensures that no one
will have unauthorized access to your user account. A user must have to be authenticated using a password before
access to server will be given. To change your password, use the command: passwd.
You will be prompted by the server of your old password and then will be prompted to input a new password. You will
have to re-type your new password for verification. You can change your password anytime. Password must have at
least six characters with any alphanumeric combination (at least for Linux) but is case sensitive.
Step 7 At the command prompt, type “passwd”.
7a. Enter your current password when prompted for the old password.
7b. Enter the password “h3ll0”, when prompted for the new password.
7c. Was the password rejected? Why was it rejected?
________________________________________________________________________
_________________________________________________________________________
7d. Enter the password “r3ch3tt” when prompted for the new password.
7e. Was the password was accepted? Why was it accepted?
________________________________________________________________________
_________________________________________________________________________
7f. What is the message when the password was successfully changed?
________________________________________________________________________
_________________________________________________________________________
4
Step 8 At the command prompt, type “passwd“ again. Type the current password as “R4ch3tt”.
8a. Was the password rejected? Why was it rejected?
________________________________________________________________________
_________________________________________________________________________
8b. What is the message when the password was not successfully changed?
________________________________________________________________________
_________________________________________________________________________
Step 9 At the command prompt, type “passwd“ again. Enter the current password. Use your desired password when
prompted for a new password. Remember your new password.
9a. Were you able to give a new password on your first try? What were the messages from the server?
________________________________________________________________________
_________________________________________________________________________
1.5. Basic File Management
Unix file system, like other file systems of other operating systems, consists of files and each file has a file name.
There are three kinds of files on your Unix system: ordinary, special and directories.
The Unix file system is organized as a hierarchy of directories where each directory can contain files or subdirectories.
This hierarchy is called a tree where the root (/) is the top of the tree.
Each file in a directory has a file identifier (this is not synonymous to file name), which is a sequence of characters that
uniquely identifies a file or directory. A file identifier can have at most 255 characters (this includes extension); any
printable character can be used as to name a file but cannot contain “/”. Although the characters “*”, “?”, “>”, “>” or “|”,
it is not recommended because it has special meaning. Remember that filenames in Unix are case sensitive.
File names in Unix, contains a sequence of file identifiers that designates a file. Slashes “/” are used to separate the
sequence of file identifiers. There are two kinds of file name: absolute and relative file name. Absolute file name
specifies the sequence of directories starting from the root (it actually starts with a “/”) and can be used to refer to a file
anywhere in the tree. Relative file name’s starting point is the current directory or working directory. Relative file name
can use symbols “.” and “..” which represents the current directory and parent directory respectively. Another symbol
“~”, represents the home directory. Home directory is the personal directory of a user where your files can be stored.
In order to do basic file management, there are several basic commands that can be used. Usual commands needed
are to list files in a directory, change to another directory, create a new directory, move a file or directory, copy a file or
directory, and remove a file or directory. Most of the commands can use absolute or relative filenames. The commands
are presented in a table below.
5
1.5.1. Changing to different directories
The “cd” command is used to change the working directory. Every time you log in via Telnet, you will be in your home
directory. Most of the time, your directory is located in the “/home” parent directory. The hierarchy can be shown as:
The hierarchy shown is very simple. This is not the whole hierarchy for the Unix system. Also, not all hierarchy is the
same for all Unix versions.
Step 10 While you are in the home directory, type the command “pwd”.
10a. What was the message on the screen?
________________________________________________________________________
_________________________________________________________________________
10b. What does the “pwd” command do?
________________________________________________________________________
_________________________________________________________________________
Step 11 Type the command “cd /etc” and press enter.
11a. Did the prompt display differently? Write down the display.
________________________________________________________________________
_________________________________________________________________________
11b. Type the command “pwd”. What is your current working directory?
________________________________________________________________________
_________________________________________________________________________
6
Step 12 From the “/etc” directory, type the command “cd /home/<username>”.
12a. Did you go to your “home” directory? How were you able to determine?
________________________________________________________________________
_________________________________________________________________________
12b. What was the file name used (absolute or relative file name)? Why?
________________________________________________________________________
_________________________________________________________________________
12c. On the command prompt, type “cd ../../etc” and press enter. Were you able to go to the “/etc” directory?
What was the file name used (absolute or relative file name)? Why?
________________________________________________________________________
_________________________________________________________________________
12d. From the “/etc” directory, type the command “cd ~”. Were you able to go to the “home” directory? Which “cd”
command is this similar to?
________________________________________________________________________
_________________________________________________________________________
1.5.2. Listing Directories
The “ls” command is used to list directories. There are a lot of options you can do with the command. It is able to
display all files, directories only and other more options.
Step 13 On the command prompt, type the command “cd ..” and press enter.
13a. Enter the “ls” command. What did you see?
________________________________________________________________________
_________________________________________________________________________
13b. Enter the “ls -A” command. What is the option? Was it different from last time?
________________________________________________________________________
_________________________________________________________________________
13c. Enter the “ls -a” command. What is the option? Was it different from last time? What does it do?
________________________________________________________________________
_________________________________________________________________________
The “ls” command with option “A”, shows all files in the directory including hidden files. Hidden files are files that
start with “.”. The “a” option has the same function as “A” option except that it also displays the “.” (current) and “..”
(parent) directories.
7
13d. Enter the “ls -l” command. What is the option? Was it different from last time? What does it do?
________________________________________________________________________
_________________________________________________________________________
The first column on the “ls -l” shows the file permission of the file or directory (again, will be discussed later).
Notice that a “d” as the first character shows which are the directories.
13e. Enter “cd /etc” and then the “ls -d rc0.d” command. What is the option? What does it do? Is it different from the “ls
rc0.d” command?
________________________________________________________________________
_________________________________________________________________________
The “d” displays if the “rc0.d” directory is there or not. While the “ls” command without the “d” option will display
the contents of the directory “rc0.d”.
13f. Enter the “ls -R” command. What is the option? What does it do? How is it different from “ls”.
________________________________________________________________________
_________________________________________________________________________
The “R” option displays the directories recursively.
Step 14 Metacharacters are characters with special meaning in Unix. One of the metacharacters is “*”.
14a. Go to the “/home/dir1” directory, type the command “ls f*”. What files were listed?
________________________________________________________________________
_________________________________________________________________________
14b. Enter the command “ls p*”. What files were listed?
________________________________________________________________________
_________________________________________________________________________
14c. Enter the command “ls file?”. What files were listed?
________________________________________________________________________
_________________________________________________________________________
14d. What is the difference between the commands “ls f*” and “ls file?”?
________________________________________________________________________
_________________________________________________________________________
14e. Enter the command “ls [f..p]ile1”. What files were listed?
________________________________________________________________________
_________________________________________________________________________
8
14f. Enter the command “ls [f..p]ile2”. What files were listed?
________________________________________________________________________
_________________________________________________________________________
14g. Enter the command “ls [f..p]ile?”. What files were listed?
________________________________________________________________________
_________________________________________________________________________
14h. What does the metacharacter “[..]” do?
________________________________________________________________________
_________________________________________________________________________
The metacharacter “*” is a wildcard for multiple characters while “?” is wildcard for a single character. The
metacharacter “[..]” is used to specify a range of characters.
1.5.3. Creating Directories
Directories in the Unix operating system can be created using the “mkdir” command. Naming directories has the same
rules as naming files. Exercises on filenames will be tackled later.
Step 15 Go to your home directory by entering the command “cd ~”. Then create a directory “coffees” using the
command “mkdir coffees”.
15a. Was the directory created?
________________________________________________________________________
_________________________________________________________________________
15b. Enter the command “cd coffees” and press enter. Next, enter the command “mkdir beans/robusta”. Were
you able to create the directory?
________________________________________________________________________
_________________________________________________________________________
15c. Enter the command “mkdir -p beans/robusta”. Were you able to create the directory? Why do you think so?
What is the “p” option for?
________________________________________________________________________
___________________________________________________________________________________________
The “p” option allows creation of directories with its parent directory.
1.5.4. Filenames
Empty files are files with a size of zero bytes. The “touch” command can be used to create empty files. The “touch”
command will be used to practice creating files with different filenames.
In Unix, filenames can have up to 255 printable characters except for the “/” character. Although “*” and “?” can be
used, these characters have special meaning.
9
Step 16 While in the directory “coffees/beans/robusta”, enter the command “touch robusta.txt”.
16a. Were you able to create the file? What is the size of the file? How were you able to determine the file size?
________________________________________________________________________
___________________________________________________________________________________________
16b. Enter the command “touch robusta/txt“. Were you able to create the file? Why? What was the message?
________________________________________________________________________
___________________________________________________________________________________________
16c. Enter the command “touch robusta1“. Were you able to create the file? Why?
________________________________________________________________________
___________________________________________________________________________________________
16d. Enter the command “mkdir robusta.doc“. Were you able to create the directory? Why?
________________________________________________________________________
___________________________________________________________________________________________
16e. Enter the command “ls“. Can you tell which one is a directory? What command should be used to be able to
determine which one is a directory?
________________________________________________________________________
___________________________________________________________________________________________
16f. Enter the command “ls robusta*“. Is there a difference from the earlier command? Can you tell which one is
the directory? Why?
________________________________________________________________________
___________________________________________________________________________________________
1.5.5. Copying Files
The cp command is used to copy files. The command can be used to copy one source to a destination or multiple
sources to a directory.
Step 17 Enter the command “cp robusta.txt robusta.html”.
17a. What happened after entering the command? Did you see the file “robusta.html”?
________________________________________________________________________
___________________________________________________________________________________________
17b. Enter the command “cp robusta.txt robusta.doc”. What happened after entering the command? Did you
see the file “robusta.doc“? Why?
________________________________________________________________________
___________________________________________________________________________________________
10
17c. Enter the command “cp robusta.txt robusta.html”. Were you prompted if the file was to be overwritten?
Why?
________________________________________________________________________
___________________________________________________________________________________________
17d. Enter the command “cp –i robusta.txt robusta.html”. Were you prompted if the file was to be
overwritten? Why?
________________________________________________________________________
___________________________________________________________________________________________
1.5.6. Moving Files
In the Unix operating system, moving of files can be done by using the command “mv”. The command can also be
used to rename files.
Step 18 Enter the command “mkdir -p ../arabica” and press enter. Next, enter the command “touch
arabica.txt”. Use the command “ls” to verify the file is existent.
18a. Enter the command “mv arabica.txt ../arabica”. Is the file “arabica.txt” still there? Where is it located now?
What did the command “mv” do?
________________________________________________________________________
____________________________________________________________________________________
18b. Enter the command “touch arabica.txt” under the directory “<home
directory>/coffees/beans/robusta”. Next, type the command “mv arabica.txt ../arabica”. What happened?
Were you prompted that you will be overwriting a file?
________________________________________________________________________
_____________________________________________________________________________________
18c. Enter the command “touch arabica.txt” under the directory “<home
directory>/coffees/beans/robusta”. Next, type the command “mv –i arabica.txt ../arabica”. What
happened? Were you prompted that you will be overwriting a file?
________________________________________________________________________
_____________________________________________________________________________________
Answer no to the prompt.
18d. Enter the command “mv arabica.txt arabica.doc”. What happened? Is the file still there? Why?
________________________________________________________________________
_____________________________________________________________________________________
11
The command can be used to rename files.
18e. What is the difference between the command “cp arabica.txt ../arabica” and “mv arabica.txt
../arabica”. Explain.
________________________________________________________________________
_____________________________________________________________________________________
1.5.7. Removing Files
Removing or deleting files can be accomplished by using the command “rm”. Be careful in using this command since
deleted file are unrecoverable.
Step 19 Go to the “<home directory>/coffees/beans/robusta” directory. Type the command “rm arabica.doc”.
19a. Was the file still there? Can it be found in another directory? Why?
________________________________________________________________________
_____________________________________________________________________________________
Step 20 Enter the command “rm *”.
20a. What happened? Which file or directory was retained?
________________________________________________________________________
_____________________________________________________________________________________
20b. Why was it retained?
________________________________________________________________________
_____________________________________________________________________________________
Step 21 Go to the “robusta.doc” directory. Create the following directory “bean_quality” and
“bean_quality/perfect_cup”.
21a. Go to the “<home directory>/coffees/beans/robusta”. Enter the command “rm robusta.doc”. Were you
able to remove the directory? Why?
________________________________________________________________________
_____________________________________________________________________________________
21b. Enter the command “rm -r robusta.doc”. Were you able to remove the directory? Why? What is the option “r” for?
________________________________________________________________________
_____________________________________________________________________________________
Step 22 Go to the “arabica” directory. Enter the command “rm –i arabica.txt”.
22a. Was the file erased immediately? What was the message?
________________________________________________________________________
_____________________________________________________________________________________
12
22b. Answer “y” to the prompt. Was the file removed? What is the option “i” for?
________________________________________________________________________
_____________________________________________________________________________________
22c. Go to the “<home directory>/coffees” directory and enter the command
“rm -ir robusta.doc”. Were prompted before removal? What was the message?
________________________________________________________________________
_____________________________________________________________________________________
Answer “n” to the prompt.
1.6. Logging Out
The “exit” command can be used to log out of the Unix server.
Step 23 At the prompt type the command “exit”.
23a. What happened? Were you able to log out? Is there an alternative command? (You may research this on books
or in the Internet)
________________________________________________________________________
_____________________________________________________________________________________
13

More Related Content

PDF
Operating System Lab Manual
PDF
Lpi Part 3 Intermediate Administration
PDF
Lpi Part 2 Basic Administration
DOCX
Unix lab manual
PDF
Gnu study guide linux admin 1 (lab work lpi 102) v 0.2
PPS
QSpiders - Unix Operating Systems and Commands
PDF
PDF
Gnu study guide linux admin 1 (lab work lpi 101) v 0.2
Operating System Lab Manual
Lpi Part 3 Intermediate Administration
Lpi Part 2 Basic Administration
Unix lab manual
Gnu study guide linux admin 1 (lab work lpi 102) v 0.2
QSpiders - Unix Operating Systems and Commands
Gnu study guide linux admin 1 (lab work lpi 101) v 0.2

Similar to Post Lab activity1 (20)

RTF
A basic unix overview(2)
PPTX
unix class 2 old scheme vtu syllabus old data
PPSX
Unix environment [autosaved]
PDF
UNIX CLASS 2 PPT for reference found in sysyem
DOC
58518522 study-aix
PDF
Linux for beginners
PPTX
Unix Shell Script - 2 Days Session.pptx
PPTX
Red hat linux essentials
PPTX
Chapter 2 unix system commands
PPT
Unix tutorial-08
PPT
PPTX
Chapter 2 Introduction to Unix Concepts
PPT
linux-commands.ppt
PPT
linux-commands.ppt
PPT
Linux commands
PPT
linux-commands.ppt
PPT
linux-commands.ppt
PPT
linux-commands.ppt
PPT
linux-commands.ppt
PPT
Intro commandline
A basic unix overview(2)
unix class 2 old scheme vtu syllabus old data
Unix environment [autosaved]
UNIX CLASS 2 PPT for reference found in sysyem
58518522 study-aix
Linux for beginners
Unix Shell Script - 2 Days Session.pptx
Red hat linux essentials
Chapter 2 unix system commands
Unix tutorial-08
Chapter 2 Introduction to Unix Concepts
linux-commands.ppt
linux-commands.ppt
Linux commands
linux-commands.ppt
linux-commands.ppt
linux-commands.ppt
linux-commands.ppt
Intro commandline
Ad

More from Dwight Sabio (20)

PPTX
Human Rights Observatory Description
PDF
RIGHTS-BASED SUSTAINABLE DEVELOPMENT GOALS MONITOR
PDF
Report on Girl Children: A Rapid Assessment of their Situation
PDF
Gender ombud report 2016 final
DOCX
Strengthening legal referral mechanisms on cases of gender
PPTX
IP Report
PDF
CPU scheduling ppt file
PDF
Ch3OperSys
PDF
OperatingSystemChp3
PDF
ABC Supermarket
PDF
Programming Problem 3
DOCX
Lab Activity
PPTX
Bluetooth
PDF
Programming Problem 2
PDF
Arduino e-book
DOC
Midterm Project Specification
DOC
Game Design Document
DOC
Class diagram
DOCX
Midterm Project
PDF
ProgrammingProblem
Human Rights Observatory Description
RIGHTS-BASED SUSTAINABLE DEVELOPMENT GOALS MONITOR
Report on Girl Children: A Rapid Assessment of their Situation
Gender ombud report 2016 final
Strengthening legal referral mechanisms on cases of gender
IP Report
CPU scheduling ppt file
Ch3OperSys
OperatingSystemChp3
ABC Supermarket
Programming Problem 3
Lab Activity
Bluetooth
Programming Problem 2
Arduino e-book
Midterm Project Specification
Game Design Document
Class diagram
Midterm Project
ProgrammingProblem
Ad

Recently uploaded (20)

PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PPTX
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PPTX
Oracle Fusion HCM Cloud Demo for Beginners
PDF
CCleaner Pro 6.38.11537 Crack Final Latest Version 2025
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
17 Powerful Integrations Your Next-Gen MLM Software Needs
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PPTX
L1 - Introduction to python Backend.pptx
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PPTX
assetexplorer- product-overview - presentation
PDF
Digital Systems & Binary Numbers (comprehensive )
PDF
Nekopoi APK 2025 free lastest update
PPTX
history of c programming in notes for students .pptx
PPTX
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
PDF
iTop VPN 6.5.0 Crack + License Key 2025 (Premium Version)
PDF
Cost to Outsource Software Development in 2025
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
Wondershare Filmora 15 Crack With Activation Key [2025
Oracle Fusion HCM Cloud Demo for Beginners
CCleaner Pro 6.38.11537 Crack Final Latest Version 2025
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Design an Analysis of Algorithms I-SECS-1021-03
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
17 Powerful Integrations Your Next-Gen MLM Software Needs
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
L1 - Introduction to python Backend.pptx
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
assetexplorer- product-overview - presentation
Digital Systems & Binary Numbers (comprehensive )
Nekopoi APK 2025 free lastest update
history of c programming in notes for students .pptx
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
iTop VPN 6.5.0 Crack + License Key 2025 (Premium Version)
Cost to Outsource Software Development in 2025

Post Lab activity1

  • 1. Laboratory Activity 1 Name: __________________________________ Date: _____________ Unix Basic Commands 1.0 Unix / Linux Command Line Interface (CLI) Basics – Basic Commands This section of the course provides a discussion and hands-on guide on the basic CLI commands in Unix/Linux. The basic CLI commands are: how to log-in, log-out, interpreting the command prompt, how to enter commands, basic file commands and management, and simple file permission. The objectives of this section are: • Familiarize the students on how to gain access to a Unix/Linux server. • Familiarize the students on what is the prompt and how to enter commands. • Familiarize the students on file identifiers and, relative and absolute file names. • Familiarize the students on basic file commands and management. 1.1. Logging In To access a Unix/Linux server, a Telnet or SSH client software can be used to connect to the server. Most operating system today has some form of this software like “putty.exe”. A login prompt for a Unix server can look like: Login: <username> Password: Before you try to log-in to a Unix server, ask your instructor for a user account, and the IP address or server name where your account is valid. After acquiring the user account and the server you are assigned to, accomplish the following: Step 1 On your Windows operating system, use an ssh client program to connect to the Unix server. Using the “putty” client program, enter the IP address or name of the Linux server in the “Host Name” text box and click the “Open” button. 1
  • 2. Step 2 At the login prompt, type your assigned username and password. 2a. Were you able to login? How were you able to login? _________________________________________________________________________ _________________________________________________________________________ 2b. Did you have a user account when you logged-in? _________________________________________________________________________ _________________________________________________________________________ 2c. What is the IP address or server name of the Unix server you logged into? _________________________________________________________________________ _________________________________________________________________________ 1.2. The Command Prompt After you have logged-in, notice that a prompt will appear on the screen. A prompt is an interface that allows user to input commands. Different shells use different faces of prompts (shells will be tackled later in the course). In this server, you will be greeted with: Notice the different parts of your prompt. For the example prompt, it has displayed the username, current directory you are in, the computer name and the prompt sign. Step 3 Write down the prompt on your screen. _________________________________________________________________________ _________________________________________________________________________ 3a. Is your username displayed on the prompt? What is your username? _________________________________________________________________________ _________________________________________________________________________ 3b. Is a computer name displayed on the prompt? What is the computer name? _________________________________________________________________________ _________________________________________________________________________ 2
  • 3. 3c. What is the prompt sign on your screen? _________________________________________________________________________ _________________________________________________________________________ 1.3. Entering Commands Commands can be entered to the Unix server via the command prompt. This is usually done by typing a series of characters after the prompt sign. A usual format in entering commands is: [dwight@netopsy1 greg]$ command <options> <argument> Options for the command are switches that tell a command to do something differently. Arguments are information sometimes needed by the command to be able to execute properly. Most of the time, options and arguments are not needed in a command. There are also commands wherein you do not need to type anything. These commands are: ctrl-c, ctrl-d, ctrl-s, and ctrl-d. The table below gives a short description. Step 4 On the command prompt, type “man –S 1 pwd” and press enter. This command will be tackled later in the course, for now just accept it. 4a. What is the option in the command? _________________________________________________________________________ _________________________________________________________________________ 4b. What is the argument in the command? _________________________________________________________________________ _________________________________________________________________________ 4c. Press “q” to exit the command. _________________________________________________________________________ _________________________________________________________________________ Step 5 On the command prompt, type “top” and press enter. 5a. Press the control and “c” key at the same time. What happened? Did it have the same effect as pressing “q”? Why” _________________________________________________________________________ _________________________________________________________________________ 3
  • 4. Step 6 On the command prompt, type ”man chmod” and press enter. 6a. Press the spacebar. Did the screen scroll up? _________________________________________________________________________ _________________________________________________________________________ 6b. Press the control and “s” key at the same time and then press the spacebar. Did the screen scroll up? Why? _________________________________________________________________________ _________________________________________________________________________ 6c. This time press the control and “q” key at the same time. What happened? ________________________________________________________________________ _________________________________________________________________________ 6d. What does the command “ctrl-s” and “ctrl-q” do? ________________________________________________________________________ _________________________________________________________________________ 1.4. Changing Password One of the first things you must do on your user account is to change your password. Password ensures that no one will have unauthorized access to your user account. A user must have to be authenticated using a password before access to server will be given. To change your password, use the command: passwd. You will be prompted by the server of your old password and then will be prompted to input a new password. You will have to re-type your new password for verification. You can change your password anytime. Password must have at least six characters with any alphanumeric combination (at least for Linux) but is case sensitive. Step 7 At the command prompt, type “passwd”. 7a. Enter your current password when prompted for the old password. 7b. Enter the password “h3ll0”, when prompted for the new password. 7c. Was the password rejected? Why was it rejected? ________________________________________________________________________ _________________________________________________________________________ 7d. Enter the password “r3ch3tt” when prompted for the new password. 7e. Was the password was accepted? Why was it accepted? ________________________________________________________________________ _________________________________________________________________________ 7f. What is the message when the password was successfully changed? ________________________________________________________________________ _________________________________________________________________________ 4
  • 5. Step 8 At the command prompt, type “passwd“ again. Type the current password as “R4ch3tt”. 8a. Was the password rejected? Why was it rejected? ________________________________________________________________________ _________________________________________________________________________ 8b. What is the message when the password was not successfully changed? ________________________________________________________________________ _________________________________________________________________________ Step 9 At the command prompt, type “passwd“ again. Enter the current password. Use your desired password when prompted for a new password. Remember your new password. 9a. Were you able to give a new password on your first try? What were the messages from the server? ________________________________________________________________________ _________________________________________________________________________ 1.5. Basic File Management Unix file system, like other file systems of other operating systems, consists of files and each file has a file name. There are three kinds of files on your Unix system: ordinary, special and directories. The Unix file system is organized as a hierarchy of directories where each directory can contain files or subdirectories. This hierarchy is called a tree where the root (/) is the top of the tree. Each file in a directory has a file identifier (this is not synonymous to file name), which is a sequence of characters that uniquely identifies a file or directory. A file identifier can have at most 255 characters (this includes extension); any printable character can be used as to name a file but cannot contain “/”. Although the characters “*”, “?”, “>”, “>” or “|”, it is not recommended because it has special meaning. Remember that filenames in Unix are case sensitive. File names in Unix, contains a sequence of file identifiers that designates a file. Slashes “/” are used to separate the sequence of file identifiers. There are two kinds of file name: absolute and relative file name. Absolute file name specifies the sequence of directories starting from the root (it actually starts with a “/”) and can be used to refer to a file anywhere in the tree. Relative file name’s starting point is the current directory or working directory. Relative file name can use symbols “.” and “..” which represents the current directory and parent directory respectively. Another symbol “~”, represents the home directory. Home directory is the personal directory of a user where your files can be stored. In order to do basic file management, there are several basic commands that can be used. Usual commands needed are to list files in a directory, change to another directory, create a new directory, move a file or directory, copy a file or directory, and remove a file or directory. Most of the commands can use absolute or relative filenames. The commands are presented in a table below. 5
  • 6. 1.5.1. Changing to different directories The “cd” command is used to change the working directory. Every time you log in via Telnet, you will be in your home directory. Most of the time, your directory is located in the “/home” parent directory. The hierarchy can be shown as: The hierarchy shown is very simple. This is not the whole hierarchy for the Unix system. Also, not all hierarchy is the same for all Unix versions. Step 10 While you are in the home directory, type the command “pwd”. 10a. What was the message on the screen? ________________________________________________________________________ _________________________________________________________________________ 10b. What does the “pwd” command do? ________________________________________________________________________ _________________________________________________________________________ Step 11 Type the command “cd /etc” and press enter. 11a. Did the prompt display differently? Write down the display. ________________________________________________________________________ _________________________________________________________________________ 11b. Type the command “pwd”. What is your current working directory? ________________________________________________________________________ _________________________________________________________________________ 6
  • 7. Step 12 From the “/etc” directory, type the command “cd /home/<username>”. 12a. Did you go to your “home” directory? How were you able to determine? ________________________________________________________________________ _________________________________________________________________________ 12b. What was the file name used (absolute or relative file name)? Why? ________________________________________________________________________ _________________________________________________________________________ 12c. On the command prompt, type “cd ../../etc” and press enter. Were you able to go to the “/etc” directory? What was the file name used (absolute or relative file name)? Why? ________________________________________________________________________ _________________________________________________________________________ 12d. From the “/etc” directory, type the command “cd ~”. Were you able to go to the “home” directory? Which “cd” command is this similar to? ________________________________________________________________________ _________________________________________________________________________ 1.5.2. Listing Directories The “ls” command is used to list directories. There are a lot of options you can do with the command. It is able to display all files, directories only and other more options. Step 13 On the command prompt, type the command “cd ..” and press enter. 13a. Enter the “ls” command. What did you see? ________________________________________________________________________ _________________________________________________________________________ 13b. Enter the “ls -A” command. What is the option? Was it different from last time? ________________________________________________________________________ _________________________________________________________________________ 13c. Enter the “ls -a” command. What is the option? Was it different from last time? What does it do? ________________________________________________________________________ _________________________________________________________________________ The “ls” command with option “A”, shows all files in the directory including hidden files. Hidden files are files that start with “.”. The “a” option has the same function as “A” option except that it also displays the “.” (current) and “..” (parent) directories. 7
  • 8. 13d. Enter the “ls -l” command. What is the option? Was it different from last time? What does it do? ________________________________________________________________________ _________________________________________________________________________ The first column on the “ls -l” shows the file permission of the file or directory (again, will be discussed later). Notice that a “d” as the first character shows which are the directories. 13e. Enter “cd /etc” and then the “ls -d rc0.d” command. What is the option? What does it do? Is it different from the “ls rc0.d” command? ________________________________________________________________________ _________________________________________________________________________ The “d” displays if the “rc0.d” directory is there or not. While the “ls” command without the “d” option will display the contents of the directory “rc0.d”. 13f. Enter the “ls -R” command. What is the option? What does it do? How is it different from “ls”. ________________________________________________________________________ _________________________________________________________________________ The “R” option displays the directories recursively. Step 14 Metacharacters are characters with special meaning in Unix. One of the metacharacters is “*”. 14a. Go to the “/home/dir1” directory, type the command “ls f*”. What files were listed? ________________________________________________________________________ _________________________________________________________________________ 14b. Enter the command “ls p*”. What files were listed? ________________________________________________________________________ _________________________________________________________________________ 14c. Enter the command “ls file?”. What files were listed? ________________________________________________________________________ _________________________________________________________________________ 14d. What is the difference between the commands “ls f*” and “ls file?”? ________________________________________________________________________ _________________________________________________________________________ 14e. Enter the command “ls [f..p]ile1”. What files were listed? ________________________________________________________________________ _________________________________________________________________________ 8
  • 9. 14f. Enter the command “ls [f..p]ile2”. What files were listed? ________________________________________________________________________ _________________________________________________________________________ 14g. Enter the command “ls [f..p]ile?”. What files were listed? ________________________________________________________________________ _________________________________________________________________________ 14h. What does the metacharacter “[..]” do? ________________________________________________________________________ _________________________________________________________________________ The metacharacter “*” is a wildcard for multiple characters while “?” is wildcard for a single character. The metacharacter “[..]” is used to specify a range of characters. 1.5.3. Creating Directories Directories in the Unix operating system can be created using the “mkdir” command. Naming directories has the same rules as naming files. Exercises on filenames will be tackled later. Step 15 Go to your home directory by entering the command “cd ~”. Then create a directory “coffees” using the command “mkdir coffees”. 15a. Was the directory created? ________________________________________________________________________ _________________________________________________________________________ 15b. Enter the command “cd coffees” and press enter. Next, enter the command “mkdir beans/robusta”. Were you able to create the directory? ________________________________________________________________________ _________________________________________________________________________ 15c. Enter the command “mkdir -p beans/robusta”. Were you able to create the directory? Why do you think so? What is the “p” option for? ________________________________________________________________________ ___________________________________________________________________________________________ The “p” option allows creation of directories with its parent directory. 1.5.4. Filenames Empty files are files with a size of zero bytes. The “touch” command can be used to create empty files. The “touch” command will be used to practice creating files with different filenames. In Unix, filenames can have up to 255 printable characters except for the “/” character. Although “*” and “?” can be used, these characters have special meaning. 9
  • 10. Step 16 While in the directory “coffees/beans/robusta”, enter the command “touch robusta.txt”. 16a. Were you able to create the file? What is the size of the file? How were you able to determine the file size? ________________________________________________________________________ ___________________________________________________________________________________________ 16b. Enter the command “touch robusta/txt“. Were you able to create the file? Why? What was the message? ________________________________________________________________________ ___________________________________________________________________________________________ 16c. Enter the command “touch robusta1“. Were you able to create the file? Why? ________________________________________________________________________ ___________________________________________________________________________________________ 16d. Enter the command “mkdir robusta.doc“. Were you able to create the directory? Why? ________________________________________________________________________ ___________________________________________________________________________________________ 16e. Enter the command “ls“. Can you tell which one is a directory? What command should be used to be able to determine which one is a directory? ________________________________________________________________________ ___________________________________________________________________________________________ 16f. Enter the command “ls robusta*“. Is there a difference from the earlier command? Can you tell which one is the directory? Why? ________________________________________________________________________ ___________________________________________________________________________________________ 1.5.5. Copying Files The cp command is used to copy files. The command can be used to copy one source to a destination or multiple sources to a directory. Step 17 Enter the command “cp robusta.txt robusta.html”. 17a. What happened after entering the command? Did you see the file “robusta.html”? ________________________________________________________________________ ___________________________________________________________________________________________ 17b. Enter the command “cp robusta.txt robusta.doc”. What happened after entering the command? Did you see the file “robusta.doc“? Why? ________________________________________________________________________ ___________________________________________________________________________________________ 10
  • 11. 17c. Enter the command “cp robusta.txt robusta.html”. Were you prompted if the file was to be overwritten? Why? ________________________________________________________________________ ___________________________________________________________________________________________ 17d. Enter the command “cp –i robusta.txt robusta.html”. Were you prompted if the file was to be overwritten? Why? ________________________________________________________________________ ___________________________________________________________________________________________ 1.5.6. Moving Files In the Unix operating system, moving of files can be done by using the command “mv”. The command can also be used to rename files. Step 18 Enter the command “mkdir -p ../arabica” and press enter. Next, enter the command “touch arabica.txt”. Use the command “ls” to verify the file is existent. 18a. Enter the command “mv arabica.txt ../arabica”. Is the file “arabica.txt” still there? Where is it located now? What did the command “mv” do? ________________________________________________________________________ ____________________________________________________________________________________ 18b. Enter the command “touch arabica.txt” under the directory “<home directory>/coffees/beans/robusta”. Next, type the command “mv arabica.txt ../arabica”. What happened? Were you prompted that you will be overwriting a file? ________________________________________________________________________ _____________________________________________________________________________________ 18c. Enter the command “touch arabica.txt” under the directory “<home directory>/coffees/beans/robusta”. Next, type the command “mv –i arabica.txt ../arabica”. What happened? Were you prompted that you will be overwriting a file? ________________________________________________________________________ _____________________________________________________________________________________ Answer no to the prompt. 18d. Enter the command “mv arabica.txt arabica.doc”. What happened? Is the file still there? Why? ________________________________________________________________________ _____________________________________________________________________________________ 11
  • 12. The command can be used to rename files. 18e. What is the difference between the command “cp arabica.txt ../arabica” and “mv arabica.txt ../arabica”. Explain. ________________________________________________________________________ _____________________________________________________________________________________ 1.5.7. Removing Files Removing or deleting files can be accomplished by using the command “rm”. Be careful in using this command since deleted file are unrecoverable. Step 19 Go to the “<home directory>/coffees/beans/robusta” directory. Type the command “rm arabica.doc”. 19a. Was the file still there? Can it be found in another directory? Why? ________________________________________________________________________ _____________________________________________________________________________________ Step 20 Enter the command “rm *”. 20a. What happened? Which file or directory was retained? ________________________________________________________________________ _____________________________________________________________________________________ 20b. Why was it retained? ________________________________________________________________________ _____________________________________________________________________________________ Step 21 Go to the “robusta.doc” directory. Create the following directory “bean_quality” and “bean_quality/perfect_cup”. 21a. Go to the “<home directory>/coffees/beans/robusta”. Enter the command “rm robusta.doc”. Were you able to remove the directory? Why? ________________________________________________________________________ _____________________________________________________________________________________ 21b. Enter the command “rm -r robusta.doc”. Were you able to remove the directory? Why? What is the option “r” for? ________________________________________________________________________ _____________________________________________________________________________________ Step 22 Go to the “arabica” directory. Enter the command “rm –i arabica.txt”. 22a. Was the file erased immediately? What was the message? ________________________________________________________________________ _____________________________________________________________________________________ 12
  • 13. 22b. Answer “y” to the prompt. Was the file removed? What is the option “i” for? ________________________________________________________________________ _____________________________________________________________________________________ 22c. Go to the “<home directory>/coffees” directory and enter the command “rm -ir robusta.doc”. Were prompted before removal? What was the message? ________________________________________________________________________ _____________________________________________________________________________________ Answer “n” to the prompt. 1.6. Logging Out The “exit” command can be used to log out of the Unix server. Step 23 At the prompt type the command “exit”. 23a. What happened? Were you able to log out? Is there an alternative command? (You may research this on books or in the Internet) ________________________________________________________________________ _____________________________________________________________________________________ 13