Linux commands are useful applications found in Linux. Commands may be used to do any simple or complicated activity. The commands are run using the Linux terminal. The terminal is a command-line interface for interacting with the system. It is similar to the Windows command prompt. Linux commands are case-sensitive. All of the commands below may be used to manipulate files and folders.
touch
- Use the “touch” command to create empty files.
- Use space between the file names to open multiple files using “touch” command.
touch elb.txt
cp
- To copy a file or directory, use the “cp” command
- To copy in the same directory, use the command:
cp file_to_copy.txt new_name.txt
- To copy in a different directory, use the command:
cp file_to_copy destination_path_of_the_directory
- To copy a directory inside another directory, use the command:
cp -r directory_to_copy/ destination_path__the_directory/
Here “r” stands for recursively (Note: to learn use of “ls” command click here).
mv
- “mv” command is used to transfer a file or directory from one place to another. For an example: “$ mv file_to_move destination_path_of_the_directory/”.
mv elb_1.txt ../Practice/
cat
- The Linux “cat” command serves a number of purposes. It is useful for many file-related tasks, including creating new files, viewing existing ones, and copying their contents.
- To create a file use “cat > file_name” then write the content and press CTRL+D.
- To view the file content use “cat file_name”.
cat elb_3.txt
head
- Using the “head” command we can view the first 10 lines of a file.
head elb.txt
tail
- Using the “tail” command we can view the last 10 lines of a file.
tail elb.txt