When is the Unix Command rmdir appropiate to use? [closed] - linux

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
I am attempting to use the Unix Command rmdir to delete a directory, but I keep getting a message:
pwd
/Users/jona/Documents/Unix-Practice
$ rmdir Unix-Practice
rmdir: Unix-Practice: No such file or directory
I am also doing this to see if I need to be above the directory to be deleted:
$ cd ..
$ pwd
/Users/jona/Documents
$ rmdir Unix-Practice
rmdir: Unix-Practice: Directory not empty
Am I using the command improperly?
I am learning from this guide http://cli.learncodethehardway.org/book/ex7.html and it is telling me to use rmdir

It seems that your directory contain some files, when directory is empty then use rmdir.
From the man page of rmdir
rmdir - remove empty directories
Remove the DIRECTORY(ies), if they are empty.
Use:
rm -r Unix-Practice to delete directory with files

Related

Unix directory deletion: [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
Improve this question
There was a directory structure on my linux server like this A/$b/
From my home directory executed a command
rm -rf A/$b.
After executing this command, The directory A itself was deleted.
Any idea what would have happened in the background?
A $ sign indicates the start of a variable in most shell languages.
If $b is not defined then your command would resolve as:
rm -rf A/
… which would delete the A directory.
To include the $ in the path you need to escape it:
rm -rf A/\$B

Trying to move a file from Documents directory into /etc/bind Linux Ubuntu [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
Improve this question
I want to move/copy a file from the Documents directory into /etc/bind I tried:
sudo mv ~/Documents/Config_Files/db.example.lan /path/to/etc/bind/
I also tried:
sudo mv ~/Documents/Config_Files/db.example.lan /path/to/~//etc/bind/
But also got the error: "No such file or directory"
I am probably being dumb but I double checked spelling capitilisation and everything is correct but still won't come up as a directory.
I can't guide you much but, as you can see we use 'sudo mv' and this means we tell root to move it and you type '~' which means home directory...
So if you type:
sudo mv ~/Documents
this means
sudo mv /root/Documents
instead of
sudo mv /home/<xyz>/Documents
Try to give proper path and let me know if it works.!
example:
sudo mv /home/<username>/Documents/Config_Files/db.example.lan /etc/bind/

How do i delete directory's in Linux (without first deleting the files inside) [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
I just gotten a Raspberry Pi for Christmas and I wanted to delete some built in programs because I wanted to make a Linux server for home use. So far I had to do this all the time using the terminal because to delete the files, you had to use root.
rm ./files/*
rmdir files
Is there any way I can use rmdir command when there are files in it?
rm -rf files will remove the files directory and all subdirectories and not prompt you with questions about file permissions.
Sure just recursive delete :)
rm -r files
In your terminal, change directories to the one in the hierarchy just above the directory in question. Then:
$mv ./dir_to_del/* .; rmdir ./dir_to_del
This will move all the files out of the directory you want to delete, and then delete the now-empty folder.

On Linux, what is the correct way to completely empty a directory without deleting it? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
Obvious solutions such as rm -rf directory/* will forget hidden files, for example. What is the correct way to do this?
My use case is the following: my directory is a subfolder of a root controlled directory, created by root and chowned to my user. If I delete it, I won't have the permissions to re-create it. However I want to make sure it's completely clean at the start of my process.
Try this :
find directory -mindepth 1 -delete
You can use:
shopt -s dotglob
rm -rf directory/*
This will delete hidden files also (starting with a dot).
Or else use find -delete:
cd directory
find . -delete
You can use
rm -rf /some/path/.* deletes all hidden files in that dir

How to turn a directory into a hidden directory [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
I have a directory /f/ssh which I would like to turn into /f/.ssh. I'm working with git-bash on win7 I've tried:
/f
$ mv /ssh /.ssh
mv: cannot stat `/ssh': No such file or directory
/f
$ mv ssh .ssh
mv: cannot move `ssh' to `.ssh/ssh'
But its not working. How can I make this happen ?
You probably want your second example (current working directory) and not root (/).
$ mv ssh .ssh
mv: cannot move `ssh' to `.ssh/ssh'
What this is saying is there is already a folder called ".ssh" in your current working directory.
By calling that command again it's also saying you don't have access to move "ssh" into the already existing ".ssh" folder.
Try an ls -al to list all current files/folders in the directory, including hidden.

Resources