tut 2 Flashcards
ls -atouch test.txt
creates a file called “test.txt”
man ls
shows all the ls commands
ls -a or ls -a -1
shows all the hidden entries (files)
ls -1
lists down all the files in a single line/single entry
ls -1 | wc -l
shows all the files in the directory
ls -1a | wc -l
shows all the files + the hidden files in the directory.
ls -a1R
shows all the content in the sub directories also
mkdir -newdir
makes a new directory
mkdir -newdir
touch -file1
ls
creates a new file called “file1” under “newdir” and ls lets us see the new file under the new directory.
mkdir -newdir
touch -file1
ls
echo “hello world”»_space; file1
cat file1
output: hello world
this script creates a new file in the new directory and adds in a sentence called “hello world”, using the cat command helps us to see the content in file1.
cp file1 file2
copies content from file1 to file2
mv file1 file3
ls
output: file2 file 3
(ls replaces the file1 with file3)
mv file3 ..
file 3 is moved to the parent directory, as known as desktop (moves 1 level up)
mv file3 ..
ls
ls /home/ict246/Desktop
OR
ls ~/Desktop
OR
ls ..
ls just shows the list of files in the current directory, so the output is file2
the last command tells us the list of files in the Desktop so file3 is included in the list of files.
mv ../file3
ls
this moves file3 from the desktop to the current directory user is working in.
output: file2 file3
cd ..
helps us to get out of the new directory we added recently and brings us back to the desktop directory we were originally working in.
rmdir new-dir
helps to remove the directory “new-dir”. if the directory cant be removed it is because there are still files inside that “new-dir”
rm -r new-dir/
removes the directory and the files inside immediately and its irreversible.
touch a{1..5}
adds in filea1, filea2, … filea5 in the current directory.
ls *
shows all the files in the current directory, and lists down the sub directories in a single line, similar to ls -1
ls a*
shows all the files that starts with “a”
ls *a
shows the files that start with “aa”
ls e
shows all the files and subdirectories that contain the letter “e”
ls ?e*
shows all the files that contain only 1 single character of letter “e”.