How to install gdb in unix without root access - unix

I am trying to install gdb in unix but i don't have root access to create files and directories in root folder. However i can only create folders in my own directories. I have followed this link http://www.tutorialspoint.com/gnu_debugger/installing_gdb.htm but every time execution fails at step 4 because it needs to create files at root level. How do I fix it?
Step1:
$ build> gzip -d gdb-6.6.tar.gz
$ build> tar xfv gdb-6.6.tar
$ build> cd gdb-6.6
Step2:
$ gdb-6.6> .⁄configure
Step3:
$ gdb-6.6> make
Step4:
$ gdb-6.6> make install
**execution fails at this point.
Or is there any other solution to install gdb in unix without root level access. Please help.

When you ./configure, you can specify --prefix which control whether software is installed.
./configure --prefix=$HOME/gdb
make
make install
Above will install gbd under $HOME/gdb.
You need to specify $HOME/gdb/bin/gdb to run the program after installation. Or adjust $PATH to include $HOME/gdb/bin:
export PATH=$PATH:$HOME/gdb/bin

Related

How to get the deb package located directory in preinst

I am creating a .deb package that would run a shell script as preinst.
The shell script needs some input files, which would be available at where I have the .deb package, as below.
Package_located_directory $ >
mydebpackage.deb
inputfile1
inputfile2
I would just transfer all the files to the different machine at any location and install it with dpkg -i mydebpackage.deb
I tried using pwd in the preinst to get the current deb file located directory.
So, I can get the path of the inputfiles from the preinst script.
But if I run pwd from preinst , it is giving me / instead of the package located directory.
Also I tried passing pwd from the PIPE to achieve this, as below,
pwd | dpkg -i mydebpackage.deb
But I do not want to depend on the user input for the path.
Please guide me for getting the current deb package located directory path from inside of preinst script.
it's better to use postinst and modify the file on your system.
for example : Modify the file /etc/test/test.txt in postinst file

Can I pass a config file directly to tmuxinator on the command-line?

I'm new to tmuxinator, so forgive me if this is a naive question.
I have a tmuxinator config file (say, my_config.yaml,) stored in a source tree of a shared project.
For others to use it, AFAICT they first have to make a soft-link from the config file to inside thier home directory, then launch tmuxinator separately:
$ ln -rs my_config.yaml ~/.tmuxinator/
$ tmuxinator my_config
This is inconvenient, and also requires that all your config files have unique filenames, lest they collide in ~/.tmuxinator/.
I'd much rather just be able to do something like:
$ tmuxinator my_config.yaml
Is there a way to pass the config file to tmuxinator on the command line?
Is there a way to pass the config file to tmuxinator on the command line?
Not currently. Feel free to open a feature request/issue on GitHub.
Tmuxinator does, however, support project level config files. If you move my_config.yml to /project/root/.tmuxinator, you can then start it (from the project root) via tmuxinator start . or tmuxinator local.
UPDATE:
As I added below in the comments, this is now possible using the -p flag:
tmuxinator start -p /path/to/my_config.yml

Symlink dotfiles

I am having trouble symlinking dotfiles. I have a folder in my home directory ~/dotfiles which I have synced to a github repo. I am trying to take my .vimrc file in ~/dotfiles/.vimrc and create a symbolic link to put it at ~/.vimrc. To do this I type in
ln -s ~/dotfiles/.vimrc ~/.vimrc
But when I run that it says
ln: /Users/me/.vimrc: File exists
What am I doing wrong?
That error message means that you already have a file at ~/.vimrc, which ln is refusing to overwrite. Either delete the ~/.vimrc and run ln again or let ln delete it for you by passing the -f option:
ln -s -f ~/dotfiles/.vimrc ~/.vimrc
There is a better solution for managing dotfiles without using symlinks or any other tool, just a git repo initialized with --bare.
A bare repository is special in a way that they omit working directory, so you can create your repo anywhere and set the --work-tree=$HOME then you don't need to do any work to maintain it.
Approach
first thing to do is, create a bare repo
git init --bare $HOME/.dotfiles
To use this bare repo, you need to specify --git-dir=$HOME/.dotfiles/ and --work-tree=$HOME, better is to create an alias
alias dotfiles='/usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME
At this point, all your configuration files are being tracked, and you can easily use the newly registered dotfiles command to manage the repository, ex :-
# to check the status of the tracked and untracked files
dotfiles status
# to add a file
dotfiles commit .tmux.conf -m ".tmux.conf added"
# push new files or changes to the github
dotfiles push origin main
I also use this way to sync and store my dotfiles, see my dotfiles repository and can read at Storing dotfiles with Git where I wrote about managing for multiple devices.
How to symlink all dotfiles in a directory recursively
Have a dotfiles directory that is structured as to how they should be structured at $HOME
dotfiles_home=~/dotfiles/home # for example
cp -rsf "$dotfiles_home"/. ~
-r: Recursive, create the necessary directory for each file
-s: Create symlinks instead of copying
-f: Overwrite existing files (previously created symlinks, default .bashrc, etc)
/.: Make sure cp "copy" the contents of home instead of the home directory itself.
Tips
Just like ln, if you want no headache or drama, use an absolute path for the first argument like the example above.
Note
This only works with GNU cp (preinstalled in Ubuntu), not POSIX cp. Check your man cp, you can install GNU coreutils if needed.
Thanks
To this and this.

How can I save the path to a frequently used directory in UNIX?

Is there a way to save the path to a frequently used directory in UNIX, so instead of having to manually cd /path/to/directory I can just enter a shortcut cd myFavoritePath ??
Define your favorite directories in CDPATH environment variable. It's a colon-separated list of search paths available to the cd command. You should specify not a directory you want to switch but parent directory.
Here is brief info about it: http://docstore.mik.ua/orelly/unix/upt/ch14_05.htm
For example you have three directories you work with frequently:
/home/user/scripts/favorite/
/var/log/
/var/lib/
add to your ~/.bash_profile (or another shell profile file you use) the next line:
export CDPATH=.:/home/user/scripts:/var
In the example below I just redefine CDPATH in shell for the current session
[user#server lib]$ CDPATH=.:/var:/home/user/scripts
[user#server lib]$ cd log
/var/log
[user#server log]$ cd lib
/var/lib
[user#server lib]$ cd favorite
/home/user/scripts/favorite
If you want use tab while execute cd you can install bash-completion http://bash-completion.alioth.debian.org/ but it's optional
Also do not forget cd - command for quick switching to previous working dir
You can always add the directory path in ~/.bashrc
vi ~/.bashrc
export FAV_DIR1=''
The variables in .bashrc load into the environment on new session. So make sure to reboot.
Then you can visit the directory by something like:
cd $FAV_DIR1

How do I install GHC 7.8.1 and assign it a different command?

I would like to install GHC 7.8.1, but would like to assign it different commands, so as not to clash with 7.6.3. For example:
runghc with runghc7.8.1
ghci with ghci7.8.1
etc...
Or similar. (ghci would be most important, for typed holes.)
Basically, I want to be able to use GHC 7.8 and 7.6, so if there is a more direct way to do this tell me (A-B problem.)
Note: Ubuntu 13.10
Because you are on a unix-like system (Ubuntu) you can do the following:
Choose a folder you like for installing ghc (e.g. in a subfolder of your home directory like $HOME/ghc7.8.1 or in a subfolder of /opt like /opt/ghc7.8.1 – I would prefer the later one if you are the only user of your computer and the first one if this isn't the case). See this wikipedia article for explanations about the unix directory structure.
Download the source code into that folder and follow the installation instructions:
See also https://ghc.haskell.org/trac/ghc/wiki/Building/Using#Runtheconfigurescript
In configure setp its important, that you set the --prefix to the folder you have chosen above (if you don't do this, ghc will be installed in /usr/local/ which you do not want)! For example:
./configure --prefix=/opt/ghc7.8.1
After the installations look for the folder with the created binaries (it will be called bin if you did not use another name for bindir). Lets imagine this folder is /opt/ghc7.8.1/bin.
Now you have two possibilities:
Solution with creating symlinks: Create symlinks in a folder which is in your $PATH pointing to the created binaries (for example /usr/local/bin or $HOME/bin – I would use the first one, if you are the only user on your computer and the second if, if you are not). Therefore you have to use the command line tool ln. For example:
sudo ln -s -T /opt/ghc7.8.1/bin/runghc /usr/local/bin/runghc7.8.1
After this command there is a file /usr/local/bin/runghc7.8.1 pointing to the binary /opt/ghc7.8.1/bin/runghc. Executing /usr/local/bin/runghc7.8.1 via typing runghc7.8.1 will now execute the runghc binary created in /opt (Note: sudo is not necessary if you create your symlink in $HOME/bin – it is just needed because root can create files under /usr)
Solution with bash aliases: Write in your $HOME/.bash_aliases (#Others: you can alternatively choose $HOME/.bashrc or $HOME/.profile depending of your system/preference) the following line:
alias runghc7.8.1='/opt/ghc7.8.1/bin/runghc'
Now typing runghc7.8.1 in your terminal is an shortcut (alias) for typing /opt/ghc7.8.1/bin/runghc and will execute this binary.
Note, that with this solution typing runghc7.8.1 will just work, when you typed it into your terminal. There are cases, when it does not work (for example calling runghc7.8.1 in a script).

Resources