I attempted to download VirtualBox from terminal. Now, when I try to update, or input a command this reads out:
tyiese#penguin:~$ apt-get update
E: Malformed entry 1 in list file /etc/apt/sources.list.d/virtualbox.list (Component)
E: The list of sources could not be read.
tyiese#penguin:~$ rm /etc/apt/sources.list.d/virtualbox.list
rm: remove write-protected regular file '/etc/apt/sources.list.d/virtualbox.list'? Y
rm: cannot remove '/etc/apt/sources.list.d/virtualbox.list': Permission denied
I did attempt to remove the file - I think - but, as you can see it was not accepted.
As for the file removal, the last line of the output you provided hints what the problem is. Given your question, I assume you're not too familiar with users and permissions in GNU/Linux. The $ sign means you're running your commands as ordinary user, whereas to modify most system/configuration files (such as those pertaining to apt) you need root privileges. You typically obtain those on a per-command basis by prepending a command with sudo. So in your case that would be:
sudo rm /etc/apt/sources.list.d/virtualbox.list
After that you would be prompted for your password and (assuming your user is allowed to do so) the command would be run as root.
As for your original problem - malformed entry in sources file - I cannot help you unless you post the contents of said file. It might be a missing keyword or missing newline at the end. Hard to say.
One remark for the future. When pasting multi-line transcripts or snippets of code, please place them between two sets of triple backquotes (```) on lines of their own for better formatting.
root cause for this error is recent update made by you.
Generally copy n paste resultant to new line to the file which for some reason is causing the file to go in invalid state.
use sudo to edit the file and remove the unnecessary line.
This will work 99%.
cheers
Related
I feel like I'm missing something very basic so apologies if this question is obtuse. I've been struggling with this problem for as long as I've been using the bash shell.
Say I have a structure like this:
├──bin
├──command (executable)
This will execute:
$ bin/command
then I symlink bin/command to the project root
$ ln -s bin/command c
like so
├──c (symlink to bin/command)
├──bin
├──command (executable)
I can't do the following (errors with -bash: c: command not found)
$ c
I must do?
$ ./c
What's going on here? — is it possible to execute a command from the current directory without preceding it with ./ and also without using a system wide alias? It would be very convenient for distributed executables and utility scripts to give them one letter folder specific shortcuts on a per project basis.
It's not a matter of bash not allowing execution from the current directory, but rather, you haven't added the current directory to your list of directories to execute from.
export PATH=".:$PATH"
$ c
$
This can be a security risk, however, because if the directory contains files which you don't trust or know where they came from, a file existing in the currently directory could be confused with a system command.
For example, say the current directory is called "foo" and your colleague asks you to go into "foo" and set the permissions of "bar" to 755. As root, you run "chmod foo 755"
You assume chmod really is chmod, but if there is a file named chmod in the current directory and your colleague put it there, chmod is really a program he wrote and you are running it as root. Perhaps "chmod" resets the root password on the box or something else dangerous.
Therefore, the standard is to limit command executions which don't specify a directory to a set of explicitly trusted directories.
Beware that the accepted answer introduces a serious vulnerability!
You might add the current directory to your PATH but not at the beginning of it. That would be a very risky setting.
There are still possible vulnerabilities when the current directory is at the end but far less so this is what I would suggest:
PATH="$PATH":.
Here, the current directory is only searched after every directory already present in the PATH is explored so the risk to have an existing command overloaded by an hostile one is no more present. There is still a risk for an uninstalled command or a typo to be exploited, but it is much lower. Just make sure the dot is always at the end of the PATH when you add new directories in it.
You could add . to your PATH. (See kamituel's answer for details)
Also there is ~/.local/bin for user specific binaries on many distros.
What you can do is add the current dir (.) to the $PATH:
export PATH=.:$PATH
But this can pose a security issue, so be aware of that. See this ServerFault answer on why it's not so good idea, especially for the root account.
I have a shell script located at "/home/pi/scripts/take-snapshot.sh" but when ever I try to execute it I get a error that the file is not present.
the following commands do not work (assuming in script directory):
/home/pi/scripts/take-snapshot.sh
./take-snapshot.sh
take-snapshot.sh
bash /home/pi/scripts/take-snapshot.sh
the following do work and will bring up the shell file (not a new file):
vi take-snapshot.sh
nano take-snapshot.sh
The most likely cause is that your file is not executable. Bash is a bit confusing in that it reports the file as "not found", even though you only don't have permissions to execute it. Run ls -l and check the permissions. The leftmost column should show an "x" at least for the current user. It will usually look something like -rwxr-xr-x for a file you have created yourself.
Run chmod +x take-snapshot.sh to fix the permissions if they don't match.
I have seen this error when the line endings are windows EOL characters. It doesn't give any other error, just the above "No file or directory".
Check the EOL character and convert it to linux EOL, if it is windows and try to run the script again.
I have visual studio 2017 and wanted to make a Cordova app. I have had many problems with it now and have found a problem. Right now I run windows 10 and have installed nodejs but npm does not work. I have tested with different command but I always get the same mistake. I have canceled Node but I can not drive.
Just posting this here to help any future wanderers,
In my case the actual issue was due to the presence of a space in my windows user name folder. Which was also clear by looking at the first line of the stack trace,
Error: EPERM: operation not permitted, mkdir 'C:\Users\FirstName'
Since there is no directory present named FirstName and the actual directory was supposed to be FirstName LastName its trying to run mkdir, for which its getting operation not permitted.
Following is how i fixed it thanks to citoreek, g8up & gijswijs
run npm config edit to edit your config, this will open up a text file in notepad or your configured editor,
then change cache path from
; cache=C:\Users\Gijs van Dam\AppData\Roaming\npm-cache
to
cache=C:\Users\GIJSVA~1\AppData\Roaming\npm-cache
Remember to remove the ; at the start,
next question would be how do we know to replace our user name with GIJSVA~1?
There are a couple of ways to target this,
Go to C:\Users open power Shell and execute following command
cmd /c dir /x
what this does is, list down all the directories in current directory along with their short names which aren't supposed to contain any spaces and normally are 6 characters or less in length. Copy that short name against your user name directory and use this in your cache path.
You will notice these short names only exist for directories either containing spaces or which are longer than 6 characters. (for the rest of the directories their short names should be same as their directory name)
If you don't want to use above command, then simply remove all the spaces from your user name in your cache path, then take the first 6 characters of the user directory name and postfix it with ~1. You should also uppercase it, but it appears not to be making any difference.
After you are done with editing this file, save your changes then try again after closing any active power shell / bash process and reopening them.
I apologize for my question. I just needed to reboot the windows.
In my case this was a permissions problem with the ~/.np* files and directories. These were owned by root by mistake. I did
sudo find "~/.np*" -exec chown myuser {} \;
and that solved it.
base path is specified in the file
.npmrc
I want to delete a file whose name is stored in a variable, but it doesn't work. I'm getting
A file or Directory in the path name does not exist
My code is
value=$(<try_text.txt)
rm -f /home/inform/output/$value
when i tried deleting i got :
cannot remove `/home/oracle/Omar2/B2BFiles/bm.txt\r': No such file or directory
where does the \r come from ?
It comes from an editor which wrote the Windows line ending \r\n to try_text.txt. When reading that file, the Linux shell removed the Unix line ending \n, and the \r remained. To get rid of it, see e. g. the answers to the question Line ending issue DOS > Linux > Java.
Try this:
value=try_text.txt
rm -f /home/inform/output/$value
Don't run the value variable in a subshell when it's not needed.
EDIT
Previously misunderstood the question, didn't see the '<'.
This works on my system:
value=$(</home/user/Documents/try_text.txt)
rm -f /home/user/Documents/$value
as #gile said, make sure the try_text.txt is in your working directory.
I am trying to edit my .mycshrc file to add in more shortcut commands in my terminal.
However, I realize there is a problem.
It appears that my file was replaced by a senior (he is gone, the same goes to the computer) and I am unable to edit it due to the permission rights where the options in the Permissions tab are all greyed out.
I tried typing chmod 644 .mycshrc and I was given the error: chmod: changing permissions of .mycshrc': Operation not permitted
Then I tried to create a new plain text document file, rename it as .mycshrc and it ain't working even as I have added in new commands unless I am doing it wrong..
The following is a sample that I am trying to add it in:
alias designer '/apps/Linux64/qt/qt-4.5.0/bin/designer'
You need to change the user, and not the file mode in this case. Use
sudo chown youruser:youruser .mycshrc
where youruser is your username.
In any case, the chmod 644 .mycshrc was failing because you aren't the owner of the file (the senior's user account is the owner most probably since he replaced it). That is precisely the reason why you need to do the above step with sudo, as the root user.
Find out a easier way to handle the problem I am facing.
Delete away the old file
Create a new file (make sure file format is the same as the old one)
Add in any new alias if necessary
type source ~/.mycshrc in command line
Viola~ It works!
Make sure you are in the directory when the file is being saved since it works for me in this manner