Find all htaccess files on server [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 7 years ago.
Improve this question
I'm looking for a Linux command to go through all the directories on my server and find all .htaccess files. The output would be a list of all those files with full path, creation/modification date and filesize.

find / -name ".htaccess" -print
Replace / with the root folder you like to start searching, in case you don't want to search the whole file system.
Wikipedia has an article about find, which also links to its man page.

It's easy with the find command.
find / -name .htaccess -exec ls -l {} \;
This will print the name, and the file details according to ls -l. Note that this is starting the search under /, which may take a long time. You might want to specify a different folder to search.

Another simple way to achieve:
locate .htaccess

find -name .htaccess

Could be as simple as
ls -l $(locate .htaccess)
if updatedb has run recently.

Related

Remove symbolic links only from a folder in tcsh [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 4 years ago.
Improve this question
I need to remove a large number of symbolic links from a folder that has other files which I don't want to remove. Is there any easy way to remove only symbolic links?
You can use the find(1) command
find . -maxdepth 1 -type l -exec rm {} \;
-maxdepth 1 is for only scanning current directory.
-type l is for searching symbolic links
-exec executes rm to delete given file, the {} being replaced by find with an appropriate path, and the \; ending the sub-command run by find
See also the man page of rm(1) (and of ls(1), mv(1), cp(1), ln(1), stat(1) if you want to use them in a variant of that find command).

Linux command that Create and Copy Files and Folder in Multiple directories [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 have websites folders in my /home directory of centos 7. i want to copy robot.txt and favicon.ico file in all websites directories.
Websites directory structure are as following:
/home/domain.com/public_html
/home/domain2.com/public_html
I want command which copy robot.txt and favicon in all websites public_html directory from /root/robots.txt and /root/favicon.ico and if file already available on the destination folder then the command will overwrite file.
Many Thanks
You can use find too.
find /home -type d -name public_html -exec cp /root/robots.txt /root/favicon.ico {} \;
Just use a simple for loop that processes each directory.
for dest in /home/domain*.com/public_html
do
cp /root/robots.txt /root/favicon.ico $dest
done

tar every subfolder named X in a bash file [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 have a folder that contains many folders and my wordpresses sites.
At the same folder i need to catch up the "uploads" subfolder and tar it named by its site.
Can anyone help me out?
Does this do the trick?
find /var/www -name uploads -a -type d | awk -F '/' '{ system("tar -czvf "$3".tar "$0) }'
The find command lists all the directories named upload under /var/www.
That's piped to awk, which splits it using the slash and runs tar. The third field is used as the file name and the whole string as the target for the tar.
This works for me: tar -cvf thisstuff.tar */uploads/*

How to delete all files expect specific file type in the folder using command line [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 lot of files in specific folder.
I want to delete all files expect *.html file type in that folder.
Is there any way to do this in command line? I am using Linux.
I'll assume that you refer to linux command line, please update your question if not.
find ./folder/to/look/in -not -iname '*.html' -exec rm {} \;
Here's an explanation of what this does
edit
If you have not too many files then you might want to make find execute one single rm command. You can do that with using + instead of ;
find ./folder/to/look/in -not -iname '*.html' -exec rm {} +
Here's an explanation of this one

How to search for a file in the CentOS command line [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 9 years ago.
Improve this question
I am using CentOS minimal version and I am trying to locate a file, but I have no idea how to search all of the server for the file.
I am sure there is a command out there to do it, can anyone help me?
Try this command:
find / -name file.look
CentOS is Linux, so as in just about all other Unix/Linux systems, you have the find command. To search for files within the current directory:
find -name "filename"
You can also have wildcards inside the quotes, and not just a strict filename. You can also explicitly specify a directory to start searching from as the first argument to find:
find / -name "filename"
will look for "filename" or all the files that match the regex expression in between the quotes, starting from the root directory. You can also use single quotes instead of double quotes, but in most cases you don't need either one, so the above commands will work without any quotes as well. Also, for example, if you're searching for java files and you know they are somewhere in your /home/username, do:
find /home/username -name *.java
There are many more options to the find command and you should do a:
man find
to learn more about it.
One more thing: if you start searching from / and are not root or are not sudo running the command, you might get warnings that you don't have permission to read certain directories. To ignore/remove those, do:
find / -name 'filename' 2>/dev/null
That just redirects the stderr to /dev/null.

Resources