1. create a file
taufanlubis@zyrex:~$ cat > testing
This is a testing file.
This is a testing file.
<ctrl+c>
taufanlubis@zyrex:~$ ls testing
testing
2. rename a file
taufanlubis@zyrex:~$ mv testing testing_new
taufanlubis@zyrex:~$ ls testing_new
testing_new
3. delete a file
taufanlubis@zyrex:~$ rm testing_new
taufanlubis@zyrex:~$ ls testing_new
ls: testing_new: No such file or directory
working with directory
1. create a directory
taufanlubis@zyrex:~$ mkdir test
taufanlubis@zyrex:~$ ls -l
total 408
………
drwxr-xr-x 2 taufanlubis taufanlubis 4096 2007-08-16 19:01 test
………
2. rename a directory
taufanlubis@zyrex:~$ mv test test_dir
taufanlubis@zyrex:~$ ls -l
total 408
………
drwxr-xr-x 2 taufanlubis taufanlubis 4096 2007-08-16 19:01 test_dir
………
3. delete a directory (if the directory is empty)
taufanlubis@zyrex:~$ rmdir test_dir/
taufanlubis@zyrex:~$ ls test_dir
ls: test_dir: No such file or directory
4. delete a directory (if not empty)
You can not use ‘rmdir’ to a not-empty directory. Let’s us make a try.
taufanlubis@zyrex:~$ mkdir test (create a directory)
taufanlubis@zyrex:~$ cd test (go to the directory)
taufanlubis@zyrex:~/test$ cat > file1 (create a file)
this is file1
<ctr-c>
taufanlubis@zyrex:~/test$ ls (check the existing file)
file1
taufanlubis@zyrex:~/test$ cd .. (go outside the directory)
taufanlubis@zyrex:~$ rmdir test (try to delete it using ‘rmdir’)
rmdir: test: Directory not empty (you will see a warning message)
taufanlubis@zyrex:~$
How to delete a not-empty directory?
You have to use ‘rm -rf’ command.
taufanlubis@zyrex:~$ rm -rf test/
taufanlubis@zyrex:~$ ls test
ls: test: No such file or directory
What is ‘rm -rf’?
‘rm’ is the same command when you use to delete a file or files. But, with an option ‘rf’, you can use it to delete a directory, even when it’s not empty.
-r, -R,
–recursive remove directories and their contents recursively
-f,
–force ignore nonexistent files, never prompt
Leave a Reply