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 1 year ago.
Improve this question
The default install directory of apt-get is /opt.
Can I change it to another directory?
Best way I can think of is to use a symbolic link
note that not all programmes are installed to the same directory and /opt may not be the best thing to move. (see end for example of moving only one folder/program)
This is what I did with EasyPeasy (Ubuntu 10.04)
Follow this code carefully some of the commands can delete important files if used incorrectly.
First you need to make sure /opt (or your distros default apt-get install directory) is empty. If you have data in the opt folder, which you most likely do, you can move it to somewhere else first for safe keeping:
sudo mkdir /New_Location/newtmp # Generates Temporary Folder for Programs
sudo cp -a /opt/* /New_Location/newtmp # Moves Programs to Temp folder
Once backed up you can remove the original directory:
sudo rm -rf /opt/ # Removes opt directory
You can then create your new Program Files folder in a drive with lots of space and create a symbolic link:
sudo mkdir /New_Location/Program-Files # Generates New Program Directory
sudo ln -s /New_Location/Program-Files /opt # Creates Symbolic Link
Finally move all your old program files to your new folder and clean up the temporary data:
sudo cp -a /New_Location/newtmp/* /New_Location/Program-Files # Moves Programs to Program Files Folder
sudo rm -rf /New_Location/newtmp/ # Removes Temp folder
If you only wanted to move a single program which is taking up a hunk of your space you could use the same process.
eg:
to move Java (JVM approx 300MB) do the following.
check directory of java using disk usage analyser.
mine is /usr/lib/jvm
sudo mkdir /New_Location/Program-Files/Java # Generates New Program Directory
sudo cp -a /usr/lib/jvm/* /New_Location/Program-Files/Java # Moves Program to new folder
sudo rm -rf /usr/lib/jvm # Removes opt directory
sudo ln -s /New_Location/Program-Files/Java /usr/lib/jvm # Creates Symbolic Link
Its best at this point to do a restart which should clear the cache.
You can't: the installation path is hard-coded in packages (see for example: http://packages.ubuntu.com/oneiric/i386/mono-runtime/filelist). This path is usually /usr instead of /opt, but it depends of the packages. If you want to override the default directory, you must extract manually the content of the packages. But, it can not work: config files, even binary files sometimes, will continue to use the old path. So you must update them in order for the packages to work correctly.
Related
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 1 year ago.
Improve this question
How do I stop MacOS updates from overwriting my auto_master file?
Every non-trivial MacOS update always removes my custom auto_master and puts in the default auto_master. I actually only add a single line to the end of the file and do not even modify the existing lines because they are irrelevant for me.
I have spent quite a bit of time figuring out automounts of NFS shares in OS X...
Somewhere along the line, Apple decided allowing mounts directly into /Volumes should not be possible:
/etc/auto_master (see last line):
#
# Automounter master map
#
+auto_master # Use directory service
/net -hosts -nobrowse,hidefromfinder,nosuid
/home auto_home -nobrowse,hidefromfinder
/Network/Servers -fstab
/- -static
/- auto_nfs -nobrowse,nosuid
/etc/auto_nfs (this is all one line):
/Volumes/my_mount -fstype=nfs,noowners,nolockd,noresvport,hard,bg,intr,rw,tcp,nfc nfs://192.168.1.1:/exports/my_share
Make sure you:
sudo chmod 644 /etc/auto_nfs
Otherwise the automounter will not be able to read the config and fail with a ... parse_entry: getmapent for map failed... error in /var/log/messages
This will not work (anymore!) though it "should".
$ sudo automount -cv
...
automount: /Volumes/my_mount: mountpoint unavailable
Note that, if you manually create the mount point using mkdir, it will mount.
But, upon restart, OS X removes the mount point, and automounting will fail.
What's the solution?
It's so easy my jaw dropped when I figured it out.
Basically, we are tricking OS X into thinking we're mounting somewhere else.
When you're talking about paths in just about any environment, the root folder is the highest path you can reach, whether it's C:\ (windows) or / (*nix)
When you're at this path, attempting to reach the parent path, via .. will keep you at the root path.
For example: /../../../../ is still just /
By now, a few of you have already figured it out.
TL;DR / Solution:
Change your /etc/auto_nfs config from (this is all one line):
/Volumes/my_mount -fstype=nfs,noowners,nolockd,noresvport,hard,bg,intr,rw,tcp,nfc nfs://192.168.1.1:/exports/my_share
For pre-Catalina: To (this is all one line)
/../Volumes/my_mount -fstype=nfs,noowners,nolockd,noresvport,hard,bg,intr,rw,tcp,nfc nfs://192.168.1.1:/exports/my_share
For Catalina and up: To (this is all one line)
/System/Volumes/Data/../Data/Volumes/my_mount -fstype=nfs,noowners,nolockd,noresvport,hard,bg,intr,rw,tcp,nfc nfs://192.168.1.1:/exports/my_share
And re-run the automounter:
$ sudo automount -cv
...
automount: /Volumes/my_mount: mounted
..... there you go! Technically /../Volumes is still /Volumes, but the automounter does not see things that way ;)
This configuration persists the mount across restarts, and creates the mountpoint automatically.
Source github : https://gist.github.com/L422Y/8697518
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 2 years ago.
Improve this question
What is the canonical way of using trailing and first slashes in Linux OS?
Which of these commands are the most canonical and preferred and unambiguous one should use in tutorials and script that are public?:
Let's say we want to tell the reader of our article to go into the "etc" folder in Ubuntu. What should we write as the command?
Here are the options I can think of:
cd etc
cd /etc
cd etc/
cd /etc/
So, which one is the less ambiguous and preferred way of telling that to our readers?
Not sure if there is a canonical version, but these are different commands:
cd etc <-- change directory to 'etc' only if 'etc' exists in the current working directory
cd /etc <-- change directory to the 'etc' directory in the root of the file system
cd etc/ <-- same as item 1. The trailing forward-slash makes it clear that this is a directory, but this isn't necessary since the 'cd' command provides ample context
cd /etc/ <-- same as item 2. The trailing forward-slash makes it clear that this is a directory, but this isn't necessary since the 'cd' command and leading forward slash provide ample context
As far as the trailing forward-slash goes, I don't think it's necessary unless you need to indicate that something is a directory when it's otherwise unclear. In most cases it's not necessary and looks awkward. As long as you're communicating what a command is/does, extra details aren't necessary.
Read documentation of GNU bash and download then study its source code (since it is free software), syscalls(2), chdir(2), path_resolution(7), credentials(7).
cd etc or cd etc/ are changing the current directory (of your bash process) to the etc directory in the current working directory.
cd /etc or cd /etc/ are changing the current directory (of your shell) to the /etc directory in the root directory . See inode(7), the stat(1) and ls(1) commands, the stat(2) system call.
You could prefer in your documentation, for readability, cd /etc/ or cd etc/ to remind your reader that /etc/ is an existing directory.
Notice the existence of the chroot(2) system call (used by the chroot(1) command) which could change the root directory (of your shell process). It is unusual to do so, and that system call can fail (like many others, see errno(3)...). In rare cases, you would use the chroot(1) command.
Also, consider changing your shell with the chsh(1) command. I prefer zsh (see file /etc/shells documented in shells(5)). You could try the es shell.
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 6 years ago.
Improve this question
When i today accessed my Ubuntu 16.04 server and wanted to remove the file "test2" it was simply not deleted!
I have used
rm test2
as well as
rm -f test2
but it still did not delete it as you can read here:
root#icinga:~# ls
basket desd.save packages scripts src test2 test5 unused
root#icinga:~# rm test2
root#icinga:~# ls
basket desd.save packages scripts src test2 test5 unused
root#icinga:~# rm -f test2
root#icinga:~# ls
basket desd.save packages scripts src test2 test5 unused
I have also tried to remove other files, didn't work!
I am the owner of "test2" and using ls -la test2 you can see that I have the rights to read and write this file!
root#icinga:~# ls -la test2
-rw-r--r-- 1 root root 9 Nov 11 20:33 test2
Using which rm it says /bin/rm.
root#icinga:~# which rm
/bin/rm
And also \rm test2 does not delete the file!
I have also checked for the name, there are no spaces at the end etc. because when I use cat test2 the correct content is shown!
I also can create a new file but can't delete this as well.
rm is also not an alias, I used unalias rm but it said "rm: not found".
Reboot did also not help.
I had the problem that I accidently deleted a file instead of moving it, so I created a script that simply moves the file to a certain directory.
Then I used nano /etc/environment and added ":/root/scripts" where this script was located!
After that i created the alias rms by using alias rms='./rm'. I know it might be dumb naming a file like a system command, I already changed it to remove!
But after doing all this there was the Error that rm can't be found and can be found in the following packages: coreutils. So i tried apt-get install coreutils but it said it is already installed.
So I first used touch /bin/rm and then chmod +x /bin/rm.
After that this problem occured!
EDIT: the problem was the /bin/rm file was empty so I set up an virtual machine and copied the required file to the server!
To remove a file, you need to be able to modify (write) in the directory that contains the file. If the file isn't deleted, then you probably don't have permission to write on the directory. This could be because the file is on a read-only file system, but it is more likely that you do not have write permission on the directory. Using rm -f suppresses error messages (and prompts).
One other possibility (probably not the case here), is that the file name has a space or other invisible character at the end, and the name you specify as a file doesn't actually exist (the file is "test2" and not "test2"; or maybe it is "test1<bs>2" where the <bs> represents a backspace, or … there are endless ways to run into problems).
Rerun rm test2; respond to the prompt; look at the error messages.
Or run ls -ld . in the directory containing the file and look at the permissions, but remember that ACLs (access control lists) and extended attributes can make it harder to work out what your permissions are (though again, they're unlikely to be a factor in the problem).
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 6 years ago.
Improve this question
I basically put down this question because I have an answer that does not (yet) have a question but I still want to share it (I don't have a blog space (yet))
So, the question is: How do I use Fedora with Windows 10 WSL (Anniversary update) in stead of Ubuntu?
This answer assumes a minimal understanding of Linux (Fedora) and a basic understanding of using the windows Run command dialog (opened via the WIN-R key combination)
My starting point was this article by Seth Jennings: https://www.variantweb.net/blog/running-fedora-on-windows-10-using-wsl/
However, I ran into some challenges that were related to symlinks and started playing around. Which resulted in the description you can find below.
I think it should not be very hard to adapt these steps to use other flavors of Linux but you will have to experiment with those. If you do have a successful installation, please let us know in the comments, including any deviations required.
I start with a clean Ubuntu installation. I anything goes wrong, you can always restart with reinstalling Ubuntu
Installing a fresh instance of Ubuntu
Press WIN-R and type cmd
lxrun /uninstall /full /y
lxrun /install /y
Select a username you want to use and replace USERNAME below with that name
lxrun /setdefaultuser USERNAME
Enter user password
Download the Fedora Docker image
open a browser to http://koji.fedoraproject.org/koji/tasks?owner=&state=closed&view=flat&method=createImage&order=-id
Select the docker image you want to use
download the file Fedora-Docker-Base-??? from the Output section
for ease sake, I will assume the file is downloaded to c:\temp and that you will be using Fedora 24
Prepare Fedora in the Ubuntu instance
Press WIN-R and type bash
sudo -i
passwd root
Enter root password twice
usermod -G wheel USERNAME # Replace USERNAME with the name you used in the lxrun command above
If you choose a different version than Fedora 24, you might want to change f24 below accordingly
mkdir /f24
cd /f24
tar Jxvf /mnt/c/temp/Fedora-Docker-Base???
a directory with a hash name will be created, I will call it $DIR
tar xvf $DIR/layer.tar
for f in bin etc lib lib64 sbin usr var; do mv $f ../$f.f24; done
cd /
cp /etc/{passwd,group,shadow,sudoers} /etc.f24
edit /etc.f24/sudoers
Disable the line that starts with %sudo
Add the following line:
%wheel ALL=(ALL:ALL) NOPASSWD: ALL # The NOPASSWD is absolutely needed or sudo will not work
exit
exit
Replace Ubuntu with Fedora
Open your favorite Windows file explorer to %LOCALAPPDATA%\lxss\rootfs
Add suffix .ubuntu to the directories: bin etc lib lib64 sbin usr var
Rename the files and directories that end in .f24 to remove the suffix .f24
If you ever want to move back to Ubuntu, simply revers these steps (rename the directories and symlinks to add the .f24 suffix and remove the .ubuntu suffix (IN THAT ORDER)) Or you can simply reinstall the Ubuntu instance
Run update and install sudo and openssh clients
Press WIN-R and type bash
su -
Enter root password you set above
dnf update -y
dnf install -y sudo openssh-clients
exit
exit
Cleanup
Either via a Windows file explorer (%LOCALAPPDATA%\lxss\rootfs) or through the bash instance (cd /), remove the directories f24 and *.ubuntu
Et voila Fedora 24 on your Windows 10 system
Many tools are not installed so you have to install them manually (openssh, tar, find, and many more)
If you want to run graphical stuff you will need an X server, Cygwin/X or VcXsrv (very small) are good tools to use
And a final after thought: You could replace %LOCALAPPDATA%\lxss\bash.ico with a nice Fedora logo to replace the Ubuntu logo, just keep the filename the same.
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 6 years ago.
Improve this question
I'm new to using mac. Could someone please help me out with the terminal commands?
cd to jump into folders right?
i tried this but it isn't working for a folder in my desktop.
Basically, I want to enter a folder on my dekstop and then go to another folder inside that. how do i do it?
The Terminal starts in your HOME folder normally. So, type
ls
to list the files and you will see the same folders and files you see when you go to HOME in the Finder. So, you will see Desktop, so now type
cd Desktop
ls
and you will see all the folders and files on your desktop. If you want to go into one called Freddy Frog now, you will need to put double quotes around it to make sure the space between Freddy and Frog is kept and it doesn't think you want to go to a folder called Freddy then one called Frog. so type
cd "Freddy Frog"
ls
and you can now go to the "Spiders from Mars" directory in there with
cd "Spiders from Mars"
ls
In general, you can just start typing the name of the folder you mean and press TAB and it will guess what you mean. So, if you start a new Terminal and type:
ls
you will see the files in your Home directory. Now type:
cd Desk<TAB>
and it will show you what it guesses you mean. That's called filename completion. If you want to know where you are currently located, use:
pwd
which will print the working directory.
If you want to return to your HOME directory at any time, just type:
cd
Two other tips for you if you are learning your way around...
Firstly, if you want Finder to open and display the directory you are currently in in the Terminal, you can run:
open .
Secondly, when Finder opens, you can turn on the Path bar at the bottom of the window by typing:
Command+Option+P
I have shown it in red - no idea why Apple ships with it turned off by default - probably explains why most Mac users I have met generally have no idea where their files are and don't know the difference between copying and moving files!
To change directory to say /usr , the command should be cd /usr
i.e. cd followed by the absolute path of the directory. For relative paths use cd ./usr where the directory usr is in your current directory.This link gives complete documentation of cd command.
Use the change directory command:
using relative paths cd ./relative/path/to/directory
using absolute paths cd /absolute/path/to/directory
IMPORTANT: do not to forget the space after cd and before the path!!!!!
On Windows, the space isn't needed for some reason...