Ubuntu Working in Terminal Lab 3
Opening Terminal By default terminal is available in GUI mode in Ubuntu 16.10. To open terminal easiest way is to 'search' function on the dash. Dash -> Search for Terminal Command ctrl+alt+t
Ubuntu File and Directories Creating Files/Directories Moving Files/Directories Copying Editing text files
Creating folders Command to create a directory: i.e mkdir mnt mkdir /Path where the directory is to be created i.e mkdir mnt
Verify the newly created folder Command ls It will list down all files and folders from the given path Refining ls command Ls –la(It will show details)
Creating New File Command is touch To verify we can use touch /path where to be created.file extention i.e touch mnt/test.txt To verify we can use ls command
Deleting files Command to delete rm /Path of the file to be deleted i.e rm mnt/test.txt
Deleting folders and their sub-folders rm -rf /Path of the directory to be deleted options '-r' which means recursive and '-f' means force
Backing up /Copying your files cp /source path/file name /Destination path /file name. i.e cp /mnt/test.txt /opt/test1.txt
Backing up / Copying your Directories cp -r /directory/to/be/copied/ /where/to/copy/to/ i.e cp /mnt/test.txt /opt/test1.txt
Moving Directories i.e mv /mnt/test /opt Command to move mv Command format mv /source /destination i.e mv /mnt/test /opt
Moving Files i.e mv /mnt/test.txt /opt Command to move mv Command format mv /source Directory/file name.ext /destination i.e mv /mnt/test.txt /opt
Saving or editing in a file Go to the file path Cd /folder name/ Now Vi test Press insert Enter text “Hello World” To save changes in file Press escape, then type “:wq!”
Class Work Create a directory using terminal in mnt folder with Directory name BSCS Create a file with your own name in BSCS folder Add text “Welcome to SZABIST” in the same file Copy this file to OPT folder with the name BSCS-Copy
Command prompt The command prompt indicates that the system is ready to accept commands. Examples include: [user@host dir]$ dir$ $ #
Command prompt The dollar sign ($) usually means you are logged in as a regular user. The hash sign (#) usually means you are logged in as root.
Some useful commands passwd: Change your password. date, cal: Find out today's date and display a calendar. who: Find out who else is active on the system. clear: Clear the screen.
Changing password The passwd command allows you to change your password Command Passwd (username) i.e passwd root This will change the password of your root account.
The date command The date command shows the current date and time. Date (enter) Possible Output (Current date of the system)
The cal command The cal command is used to view calendar Syntax of the command Cal [Moth] [Year] Example: cal 02 2010
The clear command The clear command clears your screen. Syntax of the Command clear (Enter)
The ls command The ls command lists available file and directories. Syntax of the Command ls (Enter) Some other extensions ls /dev This command will list down all hardware devices available on the system.
Thank you