Table of contents
No headings in the article.
Notice: This is to be used as a notebook and this article has no audience other than myself.
create a directory called "first":
mkdir first
create directories that are called "first1", "first2", "first3", and "first4":
mkdir first(1..4)
create the first directory and its subdirectory:
mkdir -p first/second
remove the first directory (if it's empty):
rmdir first
remove the first directory and its subdirectory (if they're empty):
rmdir -p first/second
remove the first directory and all of its subset:
rm -rf first
- -r : recursive
- -f : force
create a.txt
file:
touch a.txt
create a.txt
and write in it:
cat > a.txt
- use
ctrl + d
to save and exist
create a.txt
file and write in it until write EOF
:
cat << EOF > a.txt
- EOF : End Of File, it is a standard, you can use any string.
show content of a.txt
file:
cat a.txt
- -n: with line number
- -b: without empty lines
create a copy from a.txt
that is called b.txt
:
cp path_to_file/a.txt new_path/b.txt
create a copy from dir1
directory with all its subsets in new path that is called dir2
:
cp -r dir1/ new_path/dir2
- -r: recursive
move a.txt
file to another directory:
mv path_to_file/a.txt new_path/
move dir1
directory to the new path:
mv dir1/ new_path/
change a.txt
file name to b.txt
:
mv a.txt b.txt
change dir1
directory name to dir2
:
mv dir1/ dir2/
remove a.txt
in dir1
directory:
rm dir1/a.txt
remove dir1
directory with all its subsets:
rm -r dir1/
- -r: recursive