find specific file on ubuntu 14.04 server - find

I am trying to find MEV4_LTBP2_chr14_74992800.bam on my ubuntu 14.04 server. The below command returns an empty line however ls $HOME shows the file. Thee below should search the home directory? Removing the ~ shouls search the entire filesystem? Thank you :).
sudo find ~/ -type d -name "MEV4_LTBP2_chr14_74992800.bam"

-type d selects for directories. The.bam extension indicates that, in all likelihood,MEV4_LTBP2_chr14_74992800.bam is a regular file. Use instead:
sudo find ~/ -type f -name "MEV4_LTBP2_chr14_74992800.bam"
Better yet, omit sudo. If the file is in your home directory, you typically don't need root permissions. Use:
find ~/ -type f -name "MEV4_LTBP2_chr14_74992800.bam"

Related

How to pass find command out to scp command to copy all directories from the remote server to local directory

I tried to use this command line in Windows:
My goal is to find all the directories in root#xx.xx.xx.xx:/var/log/ for a specific port and download them locally.
For the find command, I am excluding all folders which include this name "logFolder".
set outputPath=C:\MyDestination
scp -P 22 -r 'find root#xx.xx.xx.xx:/var/log/ -type d \( ! -name logFolder \)` %outputPath%

How to remove all files starting with a certain string in particular path

I used centos 6.5
in / path I have a lot of files that started with this name tmp_
I work with a user franco who has a limit permission ( and I can't add permission to this user )
and with FileZilla when I try to delete these files, I have a permission denied message.
so the solution is to delete these files with command in putty tool
because in putty, I can use command like this sudo rm .....
but I did not find the exact command.
I found this kind of command :
rm ./-tmp_
I want only to delete the files which are only in \ path and not in its subdirectories and which started with tmp_
I work with critical system so I want to be sure before execute any command.
To find target files use :
This will just print files on console.
find / -maxdepth 1 -type f -name 'tmp_*'
To remove files (not directories):
find / -maxdepth 1 -type f -name 'tmp_*' -exec rm -f {} \;
Please use -maxdepth attribute if you want to target files to specific depth.
The command "sudo rm -rf /tmp_" is worked if the /tmp_ directory not used for you.

-bash: php: command not found - Centos6.7

I have two versions of PHP installed on the server:
$ find / -name php -type f
result:
/opt/rh/php54/root/usr/bin/php
/opt/rh/php55/root/usr/bin/php
I've added php54 path to ~/.bash_profile
$ echo $PATH
result:
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/root/bin:/opt/rh/php54/root/usr/bin/php
however $ php -v still doesn't work.
in fact if I $ cd /opt/rh/php54/root/usr/bin and run php -v from the directory itself, it still doesn't work. I get:
-bash: php: command not found
PHP is installed as there are websites running, just command line is not working...
Both
php55-php-cli-5.5.21-4.el6.x86_64
php54-php-cli-5.4.40-2.el6.x86_64
are installed...
Wrong path:
find results:
/opt/rh/php54/root/usr/bin/php
^^^--- your php binary
$PATH expects only DIRECTORIES. You listed the above path in $PATH, which means that the shell will be searching for .../usr/bin/php/php. Note the doubled php. First one is the "directory" that you added in $PATH, while the second one is the program you're trying to run. The $PATH entry should be JUST .../usr/bin/, WITHOUT the php.

Execute "find -exec" on remote maching using ksh

I am not sure if this belongs to superuser. Please excuse.
Here is what I am trying to do. I need to create a ksh script which will establish an ssh connection to a remote machine and find all ".tar" files in a particular path for a particular date and list them. Next, I will need to perform an scp command to copy all those .tar files to the server I am executing the ksh script on.
Here is what I have so far and it is far from complete... (please bear with me.. I am very new to ksh scripting).
Can someone please advise if I am going in the right direction and provide some pointers as to how I can improve and achieve what I am trying to do?
Many thanks in advance.
SSERVER=server1
SOURCEPATH=/tmp/test
sudo ssh $SSERVER \
find $SOURCEPATH -name "*.tar" -mtime +7 -exec ls {} \;
#will the above two statements work?
#I then need to output the ls results to a temp variable (i believe) and issue an scp on each of the files
#Copy files from SOURCEPATH to PATH
sudo scp "$SSERVER:$SOURCEPATH/$file1" /tftpboot
sudo scp "$SSERVER:$SOURCEPATH/$file2" /tftpboot
SSERVER=server1
SOURCEPATH=/tmp/test
sudo ssh "$SSERVER" "find $SOURCEPATH -name '*.tar' -mtime +7" |
while IFS= read -r; do
sudo scp "$SSERVER:'$REPLY'" /tftpboot
done

ubuntu server PS, ifocnfig, command not working

i am working on ubuntu server from past few months
and now suddenly ps, ifconfing commnad stop working with below error.
user1#Fb1:/usr/bin$ ps
-bash: /bin/ps: No such file or directory
any suggestions to get this command working back.
What's the output of which ps and ls /usr/bin -al (which are both in /bin also)? Does it work if you gain root privileges, either using sudo ifconfig or sudo su, then ifconfig?
This is possibly an issue with file permissions but it's hard to say without more information.
First use locate to find your ps or ifconfig program:
$ locate ps | grep bin
Also you may try whereis command:
$ whereis ps
If you don't find them, try to search as root user.
i have tried to put all the outputs of different commnads as below
root#Fb1:/usr/bin# whereis ps
ps: /bin/ps /usr/share/man/man1/ps.1.gz
root#Fb1:/usr/bin# ls -lsa ps
16 -rwxr-xr-x 1 root root 15859 2010-05-26 12:21 ps
Something wrong with your $PATH I suspect it doesn't have /sbin .. maybe new software overwrite your $PATH..
normal path should be include this (mebada is my user name)
mebada#T430:~$ echo $PATH
/home/mebada/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin