How can I get a list of repositories 'apt-get' is checking? [closed] - apt

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 want a list of repositories in sources.list, plus those in sources.list.d/.
Can I get this list in a form suitable for setting up
another host so it watches the same repositories?
Additionally, how do I determine which repository is the
source of a package, either installed or available?

It seems the closest is:
apt-cache policy

As far as I know, you can't ask apt for what their current sources are. However, you can do what you want using shell tools.
Getting a list of repositories:
grep -h ^deb /etc/apt/sources.list /etc/apt/sources.list.d/* >> current.repos.list
Applying the list:
apt-add-repository << current.repos.list
Regarding getting the repository from a package (installed or available), this will do the trick:
apt-cache policy package_name | grep -m1 http | awk '{ print $2 " " $3 }'
However, that will show you the repository of the latest version available of that package, and you may have more repositories for the same package with older versions. Remove all the grep/awk stuff if you want to see the full list.

Try this:
cat /etc/apt/sources.list

It's not a format suitable for blindly copying to another machine, but users who wish to work out whether they've added a repository yet or not (like I did), you can just do:
sudo apt update
When apt is updating, it outputs a list of repositories it fetches. It seems obvious, but I've just realised what the GET URLs are that it spits out.
The following awk-based expression could be used to generate a sources.list file:
cat /tmp/apt-update.txt | awk '/http/ { gsub("/", " ", $3); gsub("^\s\*$", "main", $3); printf("deb "); if($4 ~ "^[a-z0-9]$") printf("[arch=" $4 "] "); print($2 " " $3) }' | sort | uniq
Alternatively, as other answers suggest, you could just cat all the pre-existing sources like this:
cat /etc/apt/sources.list /etc/apt/sources.list.d/*
Since the disabled repositories are commented out with hash, this should work as intended.

All I needed was:
cd /etc/apt
nano source.list
deb http://http.kali.org/kali kali-rolling main non-free contrib
deb-src http://http.kali.org/kali kali-rolling main non-free contrib
apt upgrade && update
Source: Kali Network Repositories (/etc/apt/sources.list)

Related

Clean up terminal misstakes [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 1 year ago.
Improve this question
I am new to the terminal and was trying to install Java.
Also attempted to use homebrew, have since uninstalled.
Now everytime I open the terminal I have three lines
-bash: /opt/homebrew/bin/brew: No such file or directory
-bash: nexport: command not found
-bash: nexport: command not found
How do i remove?
Thanks
Find the Cause
First you should find the source of those commands that are automatically executed every time you log in. Usually there are files that are being executed after every login, depending on your OS it can be a bash script like bashrc in your home directory.
So first try to find the file where these commands are executed but fail:
cd ~ && grep -rnw 'nexport'
This should give you the file where nexport is executed like /home/user/bash_profile
If it does not find any file try this:
cd / && grep -nwirl 'nexport' 2>&-
This searches the whole system for nexport and prints all files where it occurs. (the extra parameter il will suppress all access-denied errors)
Same for brew (obviously)
Change affected file(s)
If you found a file, for example lets say its /home/user/bashrc assuming you have rights to write this file
type:
nano /home/user/bashr
to start editing this file using the easy-to-use, mostly preinstalled nano-editor
When editing the file type CTRL+W to start search mode and type nexport and press Enter.
It should jump to the line where nexport occurs. If it's the line you want to remove just go to its beginning and add a #.
Example:
/home/user/bash_rc#line:72
nexport foo/bar
change to:
#nexport foo/bar
to comment it out (always better than removing)
Press CTRL+X to save and try re-login.
When you installed Homebrew and then some of its packages, several configuration files have probably been modified. You need to restore them. Look maybe at /etc/profile, /etc/bashrc, /Users/<yourself>/.bashrc (replace <yourself> by your username), /Users/<yourself>/.bash_profile and /Users/<yourself>/.profile.
How to check? Try something like this:
$ grep -El '(brew|nexport)' /etc/{bashrc,profile} ~/{.bashrc,.bash_profile,.profile}
If something shows up you found the culprit. By the way, did you search the Homebrew documentation for "uninstall"?

In macOS, how can I get the manual (man) page of the original (BSD) command when I have installed a GNU alternative? [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
So I have installed GNU coreutils like so : brew install coreutils
Now I have 2 versions of my core utilities.
For example :
$>which -a stat
/usr/local/opt/coreutils/libexec/gnubin/stat
/usr/bin/stat
/usr/local/opt/coreutils/libexec/gnubin/stat is the GNU version that will be executed if I simply invoke stat And if I invoke man stat I will get the manual for that specific version.
Now my question is how can I look at the manual for the /usr/bin/stat version?
Use man -wa to list all paths, then use the specific man page you want as the argument to man.
$ man -wa stat
/usr/share/man/man1/stat.1
[some Xcode cruft deleted]
$ man /usr/share/man/man1/stat.1
Assuming you already knew that the page you wanted was in /usr/share/man, (or having learned that by running the previous command), you can use the -M option to override man's usual search.
$ man -M /usr/share/man stat
In order to retrieve a man page it must be found in the manpath. The directories that are listed by the manpath are set by /etc/manpath.config. This can be overwritten via an environment variable $MANPATH. If the man page you are looking for is in this path already, then you should see a listing like the following:
stat (1)
stat (2)
stat (3p)
stat (3p+2)
That (3p+2) represents a duplicated entry. Since you believe you have two different man pages, you should see something like this. If not, then the man page you want either does not exist on your system, or is outside of the manpath. You can specify a custom manpath with the -M option. This will override the $MANPATH variable. From the man man:
-M path, --manpath=path
Specify an alternate manpath to use. By default, man uses manpath derived code to determine the path to search. This option overrides the $MANPATH environment variable and causes option -m to be ignored.
A path specified as a manpath must be the root of a manual page hierarchy structured into sections as described in the man-db manual (under "The manual page system"). To view manual pages outside such hierarchies, see the -l option.

Where do piped files go on Windows? [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 5 years ago.
Improve this question
I was experimenting with pipelines in Git Bash. I ran "ls || vim", thinking that it would open Vim with the contents of the Directory Listing written into the editor. That is not the case, and rather, it saved the file. I haven't been able to find where, though. Any ideas?
Git Bash starts at /d/Desktop, and Git Bash is located at C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Git. Any locations this file might be would be helpful.
EDIT: Sorry, I ran "ls | vim". Also, output was:
"Warning: Input is not from a terminal
Error reading input, exiting...
Preserving Files...
Finished"
EDIT: Sorry for the off-topic post, and thank you for your answers. I'll check out SuperUser if I ever have any more similar questions.
ls || vim
See || as OR. vim is never executed because ls is not False.
ls | vim
See | as pipe. But it will give:
Vim: Warning: Input is not from a terminal
Vim: Error reading input, exiting...
Vim: preserving files...
Vim: Finished.
So use
ls | vim -
because vim will then read from standard-in.

How can I make my vim behave like my cat? [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 7 years ago.
Improve this question
Current I have the following going on, vim seems to inexplicably enter into the first folder it finds and continue tab completion from there.
When hinting a more complete name, it just gives me a bell.
~ $ cat .bash <TAB>
.bash/
.bash_history
.bash_profile
.bashrc
~ $ vim .bash <TAB>
~ $ vim .bash/ <TAB>
~ $ vim .bash/git-aware-prompt/
~ $ vim .bash_ <TAB>
<BELL>
Using vim 7.4.488 on OSX
How can I make my vim behave like my cat?
Sometimes it can happen that this is not in your .bashrc
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
. /etc/bash_completion
fi
Another possible issue can be resolved by running
complete -r vim
which can restore vim rules of completion to its default. I hope these suggestions can help you to point you in the right direction.

How would you get a webpage source from Terminal? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
The community reviewed whether to reopen this question last month and left it closed:
Original close reason(s) were not resolved
Improve this question
On my website I have a text file with data on it (The site in question is hosted by GoDaddy, so I can't access the file locally). This file is updated through PHP. From the Unix/Linux/Mac bash I would like to get the contents of the text file so I can use it in scripts. Any help would be appreciated :)
curl is installed already on your Mac, so you don't need to install it. You will also find curl installed on pretty much any Linux distribution. That's probably your safest bet.
cd ~/Desktop
curl www.google.com >> google.txt
wget can be installed on your Mac easily with Homebrew. It will likely be installed already on most Linux distributions.
cd ~/Desktop
wget www.google.com
Install MacPorts and install wget:
$ sudo port install wget
And then:
$ wget http://godaddy.com/somewhere/somefile.txt
And the resulting text file will be somefile.txt (this can be changed using the -O option).

Resources