Linux Terminal Commands; Working at linux console mode, The first command to learn is ls which is used to list the directory content. In the shell, type Code: ls / to list the content of the root directory. ------------ To list the content of a certain directory, put the directory as an argument to the command 'ls'. Type Code: ls /usr/ X11R6/ It will lead to show the contents of directory known at X11R6 available in folder usr ------------ The root directory contains all directories and files. Every Linux user account has its own home directory in the /home directory and the user's login name is used as a subdirectory in /home. Type Code: ls /home/ ------------ Use the 'touch' command to create any new file eg: tmpfile.. type: Code: touch tmpfile 'pwd' means print working directory. it is used to show current working directory. Type Code: pwd 'cd' means changing directory. 'cd /' means changing directory to the root directory. Type Code: cd / ------------ Type Code: cp tmpfile tmpfile1 The command copies the file 'tmpfile' (you have been already created using touch command ) to another file called 'tmpfile1'. ------------ Type Code: mkdir tmpdir This line of command creates a directory called tmpdir. ------------ Type Code: mv tmpfile tmpdir/ 'mv' stands for move. This command moves the file tmpfile to the directory tmpdir. The '/' sign is optional which means tmpdir is a directory. ------------ When you input Code: ls tmpdir/ So, 'tmpdir/' is relative to your current working directory. You may also list the content of the directory with its absolute path, i.e. ls /home/bdg/tmpdir/ ------------ In different types of shells, '~' refers to the user's home directory. ------------ In this case, Code: ls ~/tmpdir/ ------------ Type Code: ls -l The parameter 'l' means long listing. ------------ Use Code: ls -a You may use 'l' and 'a' together. Enter Code: ls -al .. ------------ Type Code: cd Run Code: pwd ------------ To move files, run Code: mv tmpfile1 tmpfile In the content list, the source file has been 'moved' to a new destination file. This action is equivalent to a rename. ------------ Run Code: mkdir tmpdir2 ------------ Run Code: rm tmpfile The file will disappeared. ------------ Run Code: rmdir tmpdir2 The directory tmpdir2 has disappered ------------ Run Code: rmdir tmpdir/ You are not allowed to perform this function if the directory tmpdir is not empty. Run Code: rm -r tmpdir/ ------------ Go the the /bin directory. This directory contains many of the Linux commands we frequently use. For example, Code: cp, ls, mkdir, mv, pwd, rm, rmdir and touch ------------ In your user home directory, create a directory called tmpdir1. Create an empty file in the tmpdir1 directory. View the content of that directory to make sure the file has been created. Run Code: ln -s tmpdir1/ tmpdir2/ This command links tmpdir1 to a new directory called tmpdir2. List the contents of the directory and you will see the two subdirectories. List the contents of the directory called tmpdir1and you will see the content of the directory. List the content of directory tmpdir2and you will see the content of the directory. You see that the content of tmpdir2 is the same as tmpdir1. This is because tmpdir2 is a link to tmpdir1. Go to tmpdir2 Create a new file in tmpdir2 List the content to make sure the file has been created. List the content of tmpdir1. "../tmpdir1" means going down for one level. (/home/bdg/) means going up for one level to tmpdir1 You will find that the file has also been created in the tmpdir1 directory. Linking is very useful in Linux operations. Later, you will find it especially helpful during software setup. Go to the /home directory. Create an empty file called tmpfile1. You will find that you are not permitted to create this file. |
All times are GMT +5. The time now is 11:21 AM. |
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.