You will now practice the file handling commands in Linux using the previously cloned repo that will track your work.
In a terminal window practice the touch command which is called touch.
- In your terminal type the command
man touch
and read the documentation related to the command - Type the command
touch file.txt
- Type the command
ls -ltr
and note that you now have a file called file.txt created that is 0 bytes in size
- Type the command
- Type the command
echo 'this is line one' > file.txt
- Type the command cat file.txt and note that the information this is line one is now added to file.txt
In a terminal window use the copy command which is call cp. This command is copy files on your local disk.
- In your terminal type the command
man cp
and read the documentation related to the command - In your terminal type the command
cp file.txt file2.txt
- In your terminal type the command
ls -ltr
- note that there is now a file2.txt file and that it is the same size as file.txt
- In your terminal type the command
cp file2.txt ~/Desktop
- Open a finder window a see that file.txt is copied to your desktop
In a terminal window practice the remove command which is called rm. This command is used to remove or delete files from local disk.
- Type the command
man rm
and read the documentation related to the manual for the change directory command
- press the Q button to quit out of the manual
- In your terminal type the command
touch removeme.txt
- In your terminal type the command
ls -ltr
- note you have a file called removeme.txt
- In your terminal type the command
rm removeme.txt
- In your terminal type the command
ls -ltr
- note that the file removeme.txt is gone now
In a terminal window practice the make directory command which is called mkdir.
- Type the command
man mkdir
and read the documentation related to the manual for the change directory command
- press the Q button to quit out of the manual
- In your terminal type the command
mkdir mydata
- In your terminal type the command
ls -ltr
- note you have a directory called mydata
In a terminal window practice the move command which is called mv.
- Type the command
man mv
and read the documentation related to the manual for the move command
- press the Q button to quit out of the manual
- In your terminal type the command
mv ~/Desktop/file2.txt file3.txt
- note the file2.txt file you copied to your desktop is now moved to your local directory and is called file3.txt now