Working with directory and files
mkdir dir |
create single directory dir |
mkdir dir1 dir2 |
create multiple directories dir1 dir2 |
mkdir -p dir/a/b/c |
create nested directory dir/a/b/c |
mkdir dir{1..10} |
created 10 numbered directories from dir1 to dir10 |
rm -r dir |
remove dir recursively |
touch file |
create empty file file |
touch file1 file2 |
create multiple files file1 file2 |
touch file{1..10} |
create 10 numbered files from file1 to file10 |
cp -rf /dir/file1 /dir2 |
copy file file1 to dir2 directory recursively and forcefully |
mv /dir/file1 /dir2 |
move file file1 to dir2 directory |
rm file1 |
remove file file1 |
ls -al |
show files - both regular & hidden files and their permissions |
cat file1 |
display contents of file1 |
find /dir1 -name file1 |
find file1 under /dir1 directory |
find /dir1 -perm 664 |
find all files/directories with read, write permission to owner and group, read permission for others in directory dir1 |
find /dir1 -empty -exec rm -r {}** |
find and remove all empty files/directories from /dir1 |
wc -l file1 |
count the number of lines in file1 |
wc -w file1 |
count the number of words in "file1* |
head file1 |
display top 10 lines of file1 |
head -n 20 file1 |
display top 20 lines of file1 |
tail file1 |
display last 10 lines of file1 |
tail -n 20 file1 |
display last 20 lines of file1 |
Comments