Module 2 Basic Commands
Basic commands used in LINUX
File Management related
Directory Management related
File Permission / Access Mode related
User related
Environment Variable related
General commands
Module 2.1 File Management related Commands
Commands | Options | Description |
ls | List the name of files and directories in current directory |
| -l | List the names of the files and directories in the current directory along with the permissions, date, time and size |
| f*.doc | List the name of files which name start with f and end with .doc |
| -a | List the name of files (including hidden files) and directories in current directory |
| -1 | List the name of files and directories column wise in current directory |
| -R | List the name of files and directories (including subdirectories) in current directory |
Performed Commands
Example :
File Management related
Commands | Options | Description |
cat | <filename> | Shows the content of <filename> |
| -n <filename> | Shows the content of <filename> with line numbers |
| -b <filename> | Shows the content of <filename> with line numbers but skip the blank row |
tac | <filename> | Shows the content of <filename> in reverse line order |
wc | <filename> | Shows the count of lines, words and characters of <filename> |
| -l <filename> | Shows only the lines count of <filename> |
| -w <filename> | Shows only the words count of <filename> |
| -c <filename> | Shows only the characters count of <filename> |
| <file1> <file2> | Shows the count for individual file & at end total count |
Performed Commands
File Management related
Commands | Options | Description |
echo | “string” | Print the string on screen and reach to new line |
| -n “string” | Print the string on screen and start with the same line |
| * | Print all the files and directories in current directory (same as ls) |
touch | <filename> | Create empty file with file name as <filename> |
| file{1..5} | Create multiple empty files with file name as file1 to file5 |
Performed Commands
File management related
cp | <srcfile> <destfile> | Create destination file if not & copy content of source file to it in current directory |
| <sf1> <sf2> <dir> | Create and copy content of multiple files in destination directory <dir> |
| -i <srcf> <destf> | Taking consent of user (interactive -cp: overwrite destf?) |
| -f <srcf > <destf> | Copy the content even if write permission is not given |
| -R <sdir> <ddir> | Copy the directory structure (subdirectories and files) <sdir> to <ddir> |
Performed commands
File Management Related
mv | <srcf> <destf> | Move the content of to either exist or create one |
| -i <srcf> <destf> | Move the content of source file <srcf> to the destination file <destf>. If exist by taking consent of user (interactive - mv: overwrite destf?) |
| -f <srcf> <destf> | Move the content of to even if write permission is not given |
rm | File1.txt | Remove the file <filename> from directory |
| -f file2.txt | Remove the file <filename> even if write permission is not given |
| -r file3.txt or dir1 | Remove the <dir> structure (subdirectory) |
Example :