Browse other questions tagged linux command-line or ask your own question.
Asked 11 years, 6 months ago Viewed 1. 1m times I have a VPS with Suse Linux 10. 3. I've logged in via SSH/putty and am trying to find where my web files are located. Since I'm uploading via FTP in a directory called docs, I assume that this directory exists somewhere. My google searches have taught me to do this, go to my root directory and type: find docs -type d but it says " No such file or directory ". How can I find this directory? asked Jun 28 '09 at 17:51 Edward Tanguay Edward Tanguay 12. 5k 35 gold badges 96 silver badges 126 bronze badges It is: find / -type d -name 'docs' the first parameter "/" is where to look, in this case "/" it's the entire system. -name could be -iname to ignore case also -type is not mandatory use: man find for more options terdon 47. 4k 12 gold badges 106 silver badges 157 bronze badges answered Jun 28 '09 at 18:00 OldJim OldJim 6, 926 1 gold badge 14 silver badges 6 bronze badges this command should get you what you are looking for: find / -type d -name docs that will search from the root of your server for directories with the name of docs or if you just want to search from the current directory replace the '/' with a '. '
There's no need to do that, it's already in a variable: $ echo $PWD /home/terdon The PWD variable is defined by POSIX and will work on all POSIX-compliant shells: PWD Set by the shell and by the cd utility. In the shell the value shall be initialized from the environment as follows. If a value for PWD is passed to the shell in the environment when it is executed, the value is an absolute pathname of the current working directory that is no longer than {PATH_MAX} bytes including the terminating null byte, and the value does not contain any components that are dot or dot-dot, then the shell shall set PWD to the value from the environment. Otherwise, if a value for PWD is passed to the shell in the environment when it is executed, the value is an absolute pathname of the current working directory, and the value does not contain any components that are dot or dot-dot, then it is unspecified whether the shell sets PWD to the value from the environment or sets PWD to the pathname that would be output by pwd -P. Otherwise, the sh utility sets PWD to the pathname that would be output by pwd -P. In cases where PWD is set to the value from the environment, the value can contain components that refer to files of type symbolic link.
answered Dec 11 '11 at 3:59 Panther Panther 91. 2k 16 gold badges 177 silver badges 270 bronze badges Lets say you have a folder called folder1 in your ~, inside folder1 is 1 file called file1 and 2 folders called sub1 and sub2 each with other files and folders inside them. To copy all the contents of ~/folder1 to ~/new_folder1 you would use cp -r ~/folder1/. ~/new_folder1 new_folder1 would then contain all the files and folders from folder1. cp is the command to copy using a terminal, -r makes it recursively (so, current directory + further directories inside current) ~/folder1 is the origin folder, ~/new_folder1 is the destination folder for the files/folders inside the origin. answered Dec 11 '11 at 1:23 Bruno Pereira Bruno Pereira 67. 9k 28 gold badges 188 silver badges 216 bronze badges Simple example. Copy the directory dir_1 and its contents ( files) into directory dir_2: cp -r. /dir_1. /dir_2 # or cp -r. /dir_1/. /dir_2/ # Results in:. /dir_2/dir_1/_files_ Copy only the contents ( files) of dir_1 into directory dir_2: cp -r. /dir_1/.. /dir_2 cp -r. /dir_2/_files_ _files_ is a placeholder for the actual files located in the directory.
For example, if a custom folder for the XDG_DOWNLOAD_DIR variable has named $HOME/Internet in ~/ any application that uses this variable will use this directory. Note: Like with many configuration files, local settings override global settings. It will also be necessary to create any new custom directories. Alternatively, it is also possible to specify custom folders using the command line. For example, the following command will produce the same results as the above configuration file edit: $ xdg-user-dirs-update --set DOWNLOAD ~/Internet Querying configured directories Once set, any user directory can be viewed with xdg-user-dirs. For example, the following command will show the location of the Templates directory, which of course corresponds to the XDG_TEMPLATES_DIR variable in the local configuration file: $ xdg-user-dir TEMPLATES