Cannot remove file or Directory - solaris

I have root on the server in question.
OS: Solaris 10 sparc
When I ls the audit_old directory I get:
root#z10801 audit_old # ls
qm2_ora_24871_1c.aud.gz
ls -al results in:
root#z10801 audit_old # ls -al
total 250658
drwxr-x--- 2 oraqm2 dba 128261632 Mar 6 21:55 .
drwxr-x--- 17 oraqm2 dba 512 Mar 6 20:55 ..
rm gives me:
root#z10801 audit_old # rm qm2_ora_24871_1c.aud.gz
qm2_ora_24871_1c.aud.gz: No such file or directory
rm -rf the dir gives me:
root#z10801 rdbms # rm -rf audit_old/
rm: Unable to remove directory audit_old/: File exists
Any help would be great!
Thanks!

This behavior may be due to a file currently open by a separate process.
Even though you have removed it, the file is not truly removed by the OS until the process closes the file.
Try to find out the process that has the file open by using:
$ fuser .
In the directory which has the problem.
This command will print the process Id's which have files currently in use.

Related

HowTo: Completely Uninstall Postgresql14 from MacOs Catalina If I've used the EnterpriseDB.com GUI installer

I've been trying to get this to work by following the answers in these questions:
How to uninstall postgresql on my Mac (running Snow Leopard)
Completely uninstall PostgreSQL 9.0.4 from Mac OSX Lion?
...but they're not working. So, here's what I have tried instead/in addition...
.
me#myMac:~$ cd /Library/PostgreSQL/14
me#myMac:/Library/PostgreSQL/14$ ./uninstall-postgresql.app/
-bash: ./uninstall-postgresql.app/: is a directory
me#myMac:/Library/PostgreSQL/14$ open ./uninstall-postgresql.app/
LSOpenURLsWithRole() failed with error -10810 for the file /Library/PostgreSQL/14/uninstall-postgresql.app.
me#myMac:/Library/PostgreSQL/14$ open -a ./uninstall-postgresql.app/
Unable to find application named './uninstall-postgresql.app/'
me#myMac:/Library/PostgreSQL/14$ open -a uninstall-postgresql.app/
Unable to find application named 'uninstall-postgresql.app/'
me#myMac:/Library/PostgreSQL/14$ sudo open uninstall-postgresql.app/
Password:
LSOpenURLsWithRole() failed with error -10810 for the file /Library/PostgreSQL/14/uninstall-postgresql.app.
me#myMac:/Library/PostgreSQL/14$ cd /Library/PostgreSQL/14/uninstall-postgresql.app/Contents/MacOS/
me#myMac:/Library/PostgreSQL/14/uninstall-postgresql.app/Contents/MacOS$ install
install install_name_tool installvst
install-info installer
me#myMac:/Library/PostgreSQL/14/uninstall-postgresql.app/Contents/MacOS$ installer
Usage: installer [-help] [-dominfo] [-volinfo] [-pkginfo] [-allowUntrusted] [-dumplog]
[-verbose | -verboseR] [-vers] [-config] [-plist]
[-file <pathToFile>] [-lang <ISOLanguageCode>] [-listiso]
[-showChoicesXML] [-applyChoiceChangesXML <pathToFile>]
[-showChoicesAfterApplyingChangesXML <pathtoFile>]
-pkg <pathToPackage>
-target <[DomainKey|MountPoint]>
me#myMac:/Library/PostgreSQL/14/uninstall-postgresql.app/Contents/MacOS$ installbuilder.sh
-bash: installbuilder.sh: command not found
SINCE I couldn't run/find installbuilder.sh using the following command...
me#myMac:/Library/PostgreSQL/14/uninstall-postgresql.app/Contents/MacOS$ installbuilder.sh
-bash: installbuilder.sh: command not found
...as the other answers in my OP suggest, I went on to try the steps below:
me#myMac:/Library/PostgreSQL/14/uninstall-postgresql.app/Contents/MacOS$ ls -la
total 3112
drwxr-xr-x 5 root daemon 160 Sep 23 10:48 ./
drwxr-xr-x 5 root daemon 160 Sep 23 09:18 ../
-rwxr-xr-x 1 root daemon 673 Sep 23 10:48 installbuilder.sh*
-rwxr-xr-x 1 root daemon 1449456 Sep 23 10:07 osx-x86_64*
-rwxr-xr-x 1 root daemon 135216 Jul 14 11:21 uninstall-postgresql*
me#myMac:/Library/PostgreSQL/14/uninstall-postgresql.app/Contents/MacOS$ ./installbuilder.sh
Unable to initialize installer
me#myMac:/Library/PostgreSQL/14/uninstall-postgresql.app/Contents/MacOS$ ./uninstall-postgresql
Usage: ./uninstall-postgresql installerName [args ...]
me#myMac:/Library/PostgreSQL/14/uninstall-postgresql.app/Contents/MacOS$ ./uninstall-postgresql osx-x86_64
and VOILA!!!
This launched the uninstall GUI
Choose UNINSTALL ALL / REMOVE ENTIRE INSTALLATION
The uninstaller will do its thing and then prompt you with this:
At this point you'll want to follow the steps provided in this PREVIOUS StackOverflow ANSWER - steps 3 through 6 of #user1181328's answer. I'll list them here for convenience:
Remove the PostgreSQL and data folders. The Wizard will notify you that these were not removed.
sudo rm -rf /Library/PostgreSQL
Remove the ini file:
sudo rm /etc/postgres-reg.ini
Remove the PostgreSQL user:
using System Preferences -> Users & Groups.
Unlock the settings panel by clicking on the padlock and entering your password.
Select the PostgreSQL user and click on the minus button.
Restore your shared memory settings:
sudo rm /etc/sysctl.conf
That should be all! The uninstall wizard would have removed all icons and start-up applications files so you don't have to worry about those.

Can gsutil create the psudeo-directory entries needed to speed up gcsfuse?

Although Google Cloud Storage is a flat object store that doesn't need directory entries, adding psuedo directory placeholders (empty entries with names ending in /) makes gcsfuse a lot faster. You can leave out the gcsfuse --implicit-dirs option and browse your GCS directories with very workable performance, which is not the case without the placeholders.
Q. Is there a way to issue a command to gsutil like gsutil cp -r your_directory gs://your-bucket/ that will create the directory placeholders while uploading files?
The alternative is to call the GCS API, but gsutil has a lot of useful features including parallel uploads and retry handling.
Example
Make the local tree:
$ mkdir -p your_directory/subdir
$ echo hi > your_directory/hi.txt
$ echo there > your_directory/subdir/there.txt
$ ls -lR your_directory
total 8
-rw-r--r-- 1 jerry staff 3 Jan 21 17:24 hi.txt
drwxr-xr-x 3 jerry staff 96 Jan 21 17:24 subdir/
your_directory/subdir:
total 8
-rw-r--r-- 1 jerry staff 6 Jan 21 17:24 there.txt
gsutil copy it to GCS:
$ gsutil cp -r your_directory gs://your-bucket/
Copying file://your_directory/hi.txt [Content-Type=text/plain]...
Copying file://your_directory/subdir/there.txt [Content-Type=text/plain]...
/ [2 files][ 9.0 B/ 9.0 B]
Operation completed over 2 objects/9.0 B.
$ gsutil ls -lr gs://your-bucket/your_directory
gs://your-bucket/your_directory/:
3 2020-01-22T01:25:38Z gs://your-bucket/your_directory/hi.txt
gs://your-bucket/your_directory/subdir/:
6 2020-01-22T01:25:38Z gs://your-bucket/your_directory/subdir/there.txt
TOTAL: 2 objects, 9 bytes (9 B)
Notice that gsutil only created 2 objects (blobs) -- the text files. It did not create directory placeholder blobs your_directory/ or your_directory/subdir/.
In a gcsfuse your-bucket your-bucket mount:
$ find your_directory
find: your_directory: No such file or directory
In a gcsfuse --implicit-dirs your-bucket your-bucket mount:
$ find your_directory
your_directory
your_directory/hi.txt
your_directory/subdir
your_directory/subdir/there.txt
slowly.
Back to a gcsfuse your-bucket your-bucket mount, we can make the text files show up by creating the directory placeholders:
$ mkdir your_directory
$ ls your_directory
hi.txt
$ mkdir your_directory/subdir
$ ls your_directory
hi.txt subdir/
$ ls your_directory/subdir/
there.txt
If I understood correctly and you want to upload files while creating what appear to be empty folders (which in the background are just empty files with a "/" at the end of their path), gsutil cp -r your_directory gs://your-bucket/ does the trick.
For reference here is how subdirectories work in GCS and gsutil cp command

Dockerfile copy keep subdirectory structure

I'm trying to copy a number of files and folders to a docker image build from my localhost.
The files are like this:
folder1/
file1
file2
folder2/
file1
file2
I'm trying to make the copy like this:
COPY files/* /files/
However, all of the files from folder1/ and folder2/ are placed in /files/ directly, without their folders:
files/
file1
file2
Is there a way in Docker to keep the subdirectory structure as well as copying the files into their directories? Like this:
files/
folder1/
file1
file2
folder2/
file1
file2
Remove star from COPY, with this Dockerfile:
FROM ubuntu
COPY files/ /files/
RUN ls -la /files/*
Structure is there:
$ docker build .
Sending build context to Docker daemon 5.632 kB
Sending build context to Docker daemon
Step 0 : FROM ubuntu
---> d0955f21bf24
Step 1 : COPY files/ /files/
---> 5cc4ae8708a6
Removing intermediate container c6f7f7ec8ccf
Step 2 : RUN ls -la /files/*
---> Running in 08ab9a1e042f
/files/folder1:
total 8
drwxr-xr-x 2 root root 4096 May 13 16:04 .
drwxr-xr-x 4 root root 4096 May 13 16:05 ..
-rw-r--r-- 1 root root 0 May 13 16:04 file1
-rw-r--r-- 1 root root 0 May 13 16:04 file2
/files/folder2:
total 8
drwxr-xr-x 2 root root 4096 May 13 16:04 .
drwxr-xr-x 4 root root 4096 May 13 16:05 ..
-rw-r--r-- 1 root root 0 May 13 16:04 file1
-rw-r--r-- 1 root root 0 May 13 16:04 file2
---> 03ff0a5d0e4b
Removing intermediate container 08ab9a1e042f
Successfully built 03ff0a5d0e4b
Alternatively you can use a "." instead of *, as this will take all the files in the working directory, include the folders and subfolders:
FROM ubuntu
COPY . /
RUN ls -la /
To merge a local directory into a directory within an image, do this.
It will not delete files already present within the image. It will only add files that are present locally, overwriting the files in the image if a file of the same name already exists.
COPY ./local-path/. /image-path/
I could not get any of these answers to work for me. I had to add a dot for the current directory, so that the working docker file looks like:
FROM ubuntu
WORKDIR /usr/local
COPY files/ ./files/
Also using RUN ls to verify wasn't working for me and getting it to work was looking really involved, a much easier way to verify what is in the docker file is to run an interactive shell and check out what is in there, using docker run -it <tagname> sh.
If you want to copy a source directory entirely with the same directory structure,
Then don't use a star(*). Write COPY command in Dockerfile as below.
COPY . destinatio-directory/

Problems with permissions for logrotate

I'm writing my own logrotate configuration for some web application:
/home/me/public_html/logs/*.log {
daily
missingok
rotate 15
compress
delaycompress
notifempty
create 0660 me www-data
nosharedscripts
}
But running logrotate for these files results in:
$ sudo logrotate -d -v *.log
Ignoring logfile1.log because of bad file mode.
Ignoring logfile2.log because of bad file mode.
Ignoring otherlogfile.log because of bad file mode.
Handling 0 logs
$ ls -l
-rw-rw---- 1 me www-data 893584 Jan 27 16:01 logfile1.log
-rw-rw---- 1 me www-data 395011 Jan 27 16:01 logfile2.log
-rw-rw---- 1 me www-data 4949115 Jan 27 16:01 otherlogfile.log
Is this related to the file permissions of the actual logfiles in the directory of to the permissions specified with create 0660 me www-data?
If I change the filepermissions to -rw-r----- and the create line to
create 0640 me www-data
I get
$ sudo logrotate -d -v *.log
Ignoring logfile1.log because the file owner is wrong (should be root).
Ignoring logfile2.log because the file owner is wrong (should be root).
Ignoring otherlogfile.log because the file owner is wrong (should be root).
Handling 0 logs
My system is a debian testing/jessie.
Ok, stupid situation. The logrotate command has to be executed on the configuration file instead of the log file.
$ sudo logrotate -d -v /etc/logrotate.d/my-app
It seems to be important that the parent directory of the logfile is not world writable (------rw-) and not writable by any non root group (---rw----). Otherwise, you will see:
error: skipping "/home/me/public_html/logs/logfile1.log" because parent
directory has insecure permissions (It's world writable or writable by
group which is not "root") Set "su" directive in config file to tell
logrotate which user/group should be used for rotation.

shell script not executing despite full permissions

I have a small script that executes fine from my home folder but when moved to a different folder on different partition (EXT4)
$ ls -lah ./build.sh
-rwxrwxr-x 1 olmec(me) olmec(me) 510 Oct 31 20:00 ./build.sh
$ ./build.sh
bash: ./build.sh: Permission denied
I have tried chmod 777 build.sh but no difference.
The script is in folder /media/data/source
Data drive partition is mounted in FStab as
UUID=affd0ac6-f3da-4f88-ac22-65d94dc5da8c /media/data ext4 user,user 0 0
Resolved by modifying FStab mount command
UUID=affd0ac6-f3da-4f88-ac22-65d94dc5da8c media/data ext4 auto,users,exec 0 0
Most probably it's on a volume which was mounted with the noexec option, I'd check that. If that's not the case, you can still try to find out from strace bash yourscript's output.