Unable to edit file UNIX [closed] - unix

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 am trying to edit a file in vi editor - and when I try to save the changes it says READ ONLY. Even when I try to do a chmod I get an error saying I cannot do so.
I have logged in Unix using a personal ID and not a service one

Because you aren't owner of this file. You need to sudo vim with an owner user.

Try opening editing the file in vim using: sudo vim <filename>
Some people also recommend adding this to your .vimrc file so you can open the file without sudo then write to it anyway using :w!!
" Sudo to write
cnoremap w!! w !sudo tee % >/dev/null

Related

Can I get emplacement of `sources.list` in cmd on a Modified UNIX? [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 2 years ago.
Improve this question
i would like to know how can I get the path to sources.list on a modified UNIX which have apt and other base packages on it , like gpg and sudo. Does apt can identify the path to sources.list ?
He is using it , so he should be able to locate it, right ?
I don't know if this is the best way, but apt-config dump will show all of apt's configuration variables. On my system, the Dir::Etc variable gives the directory where the file is located, and Dir::Etc::sourcelist gives its name.
You can also read in the apt-config man page about the shell option which may be more useful for processing this data in a program.

How can I search ~/Library with the command find on my mac? [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 2 years ago.
Improve this question
I want to find all the files a piece of software has left in my system.
In the terminal I type:
$ find /Users -name software -print
And every time find tries to look into a folder within the Library directory, Terminal returns "operation not permitted".
So I tried:
$ sudo find /Users -name software -print
Same result
So I finally enabled super user, logged in with command su, entered my command: same result.
1 - I do not understand why even the super user is not allowed to search the library.
2 - what is the work around?
Thanks for your help
I have found the answer.
Terminal needs to be added in the System Preferences/Security and Privacy/ full disk access!

Changing user ownership to match group? [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 mistakenly ran chown -R admin / on Centos 6
Is there any command to change user to match group? I think this should be a fix since by default user=group?
P.S. An OS reinstall can fix this, but I am looking for alternate solutions to avoid this.
Well, "admin" isn't a standard user, guess you added it or you wouldn't have such an issue.
If that command really worked I guess the first issue may be to login as root but assuming you can at lest get to the state that you can do that you have a few options (besides restore from backup or rebuild).
You can use rpm to restore owner/permission of any file handled by rpm.
rpm --setugids coreutils
or to do all of it at once (which I strongly discourage you from doing)
rpm --setugids $(rpm -qa)
dunno what the impact would be of that since when I did a quick test in lab it gave me a ton of "file not found" errors.
As for your original question, haven't seen any "user=group" option but you could do something like
find /home -user admin ! -group admin|while read i;do echo chown --no-dereference $(stat -c %g "$i") "$i";done
and if that looks good run it without "echo"
find /home -user admin ! -group admin|while read i;do chown --no-dereference $(stat -c %g "$i") "$i";done

How to rsync files with --files-from with quantifier? [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 want to move from one server to another and I won´t lost special logfiles (like mail.logs), so want to rsync the files with the --files-from option. But I can´t use a quantifier like * or {0..9} in the file list.
rsync -avR --files-from=/backup/filelists/filelist1.txt / $DESTSRV:"$DESTPATH"
for example I want to rsync all mail server log files
/var/log/mail.log
/var/log/mail.log.1
/var/log/mail.log.2.gz
/var/log/mail.log.3.gz
/var/log/mail.log.4.gz
But in the /backup/filelists/filelist1.txt I can´t use
/var/log/mail*
or
/var/log/mail.log.{2..10}.gz
I got the following error
rsync: link_stat "/var/log/mail*" failed: No such file or directory (2)
Anybody knows a solution for my problem?
After searching and trying I found another solution that fits to me:
cat /backup/fileslists/filelist1.txt | { while read line; do rsync -avzR $line "$DESTSRV":"$DESTPATH"/; done; }
This code reads the input file line by line and sync it with rsync. In this case I could use any quantifier :).

New bash session with a user from the current one [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
How can i create a new bash session with a user from the current bash session,
I know i can do it with only one command
tryin to figure it out.
$ su <user> -c bash
replace the username desired. You will either need to know the password of the user or run it as root.
or, you could do any of the following
$ screen -S <user>
$ bash --login <user>
All of which will accomplish your task
Reference Linux screen command: http://linux.die.net/man/1/screen
You can create a new session in your bash by this:
screen -S test

Resources