#unix
1 messages ยท Page 36 of 1
ok.. so I made the sh script to ssh into a bastion host
but I need to ssh into another instance from there.. how do I add this to the sh script
would this work
#! /bin/bash
eval ssh-agent $SHELL
# adding keys to ssh agent
ssh-add ~/.ssh/gcp_jump && ssh-add ~/.ssh/gcp_sourceinstance
ssh -A username@IP1 'ssh username@IP2'
I got it :3
yay me
#! /bin/bash
# start ssh agent for the script
eval $(ssh-agent)
# add the ssh keys to agent
ssh-add ~/.ssh/gcp_jump && ssh-add ~/.ssh/gcp_sourceinstance
# use the Agent and Jump server
ssh -A -J username@bastionhost username@final_destinationIP
I want to allow egress traffic on private vm to be able to install packages
what's the ip address I need to route to
guess I need to set up a NAT gateway.. whatever that is
What kind of IP does your server have?
NAT means network address translation and comes into play when a server has for example a private IP, but needs to use a public or shared ip to connect to clients. Then the router translates between the two networks. It is also used to map devices within an internal network to the public internet. You can looks up SNAT, DNAT and PNAT and their differences.
But I need more information there. @main olive
I have a private vm (with no external IP) on a VPC that I access through a bastion host.. the bastion host has an external IP
I want to install stuff on my private vm.. for some reason I'm able to run apt install as root.. I have no clue how
sudo apt install packagename
you can also become root with your user password via sudo -i, if you are in the sudoers file
I'd like to allow all users to use apt install..
I'd also like to find out how i'm able to install packages.. how is traffic going outside when I didn't configure it
Add the users you wish to allow to use apt to the sudoers file, allowing that command only. Don't give a blank permission to become root
username ALL = NOPASSWD : /usr/bin/apt , /usr/bin/aptitude
something like that
For the connectivity issue, try running ip route and check if has a default entry
It should say something like default via 10.10.10.254 dev eth0 src 10.10.10.252 metric 202 IP will be different
default route means "send all packages I don't know the destination of to that address"
I tried to run that.. it says no command called username
with ip route I got this
default via 10.0.254.1 dev eth0
10.0.254.1 dev eth0 scope link
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 linkdown
You need to replace username with an actual username or %u for all users
ahh
well, %u is the current user
yeah looks like it
Maybe it is the spaces: %u ALL=NOPASSWD:/usr/bin/apt,/usr/bin/aptitude
%u: no such job
this is weird or I am stupid, because I have lines like this in my /etc/sudoers and it works
do you mean I need to add this line somewhere
or do I run this as a command
well I added it to the file.. hopefully it works
hmm still permissions denied
I added it
%u ALL=NOPASSWD:/usr/bin/apt,/usr/bin/aptitude
You still need to type sudo and you also need to relog before it works
or use su to switch to a user
I just tried it on my raspi and it works fine ๐
yeah, now it should run without password
nicee
anyway, about your connectivity issue: Try to run ping google.com and see if you get a response
I do
then it is not a routing issue
I'm not sure why it's available externally
NAT also works fine then
I didnt set up NAT
no, the gateway does that
I mean.. it's a private vm with no external ip and I haven't allowed traffic
so i'm wondering how it's routing
it's a private VM (with only an internal IP) on a VPC.. and it's accessible from a bastion host
I was of the opinion it didn't allow any external traffic.. and was wondering how to set up NAT so i can install packages
VPC virtual private cloud.. and im using GCP..
bastion is a jump server
But isn't that the point, that you can access your private vm via the bastion server?
yes.. and I can access it
It shouldn't be accessible from the outside though
without connecting to the bastion first
but I'm wondering how the private vm is allowing network traffic to install packages
like what route is the traffic taking..
always to the next gateway
even though I run the apt install from the private vm?
I don't know what 10.0.254.1 is, but I assume it is some sort of gateway that then decides if it allows this traffic
if you want to change the route, you need to change the default route
but in networking, if a machine connects to the "outside", all incoming packages are allowed
for that request
Only if unsolicited packages come in, the firewall denies them if there are no other rules
ok.. 10.0.254.1 is the gateway on one subnet for this VPC
I'm wondering how to easily copy local files to the private vm.. hmm
use scp
it is basically ssh-copy
hence, scp
scp local_file user@host:/home/or/other/path -P port
You'll probably need to copy it to the bastion server first
hmm yeah.. probably some other way.. to do that
but I'm wondering if there's a way to use CI/CD for this stuff
are you using git? Can use a hook to achieve it
I am using CD with my NAS and Pi to build my website
after a commit, the NAS runs a bash script on my pi, which then runs Jekyll and uploads the files to my host
NAS is just my network storage, disregard it, but hooks are functions in Git that allow you to fire scripts when specific events happen, like received files.
Gitlab support them: https://docs.gitlab.com/ee/administration/server_hooks.html
Documentation for GitLab Community Edition, GitLab Enterprise Edition, Omnibus GitLab, and GitLab Runner.
like.. received files where
you mean like.. if I put a file in a certain place on git.. then it runs some script that copies it to the private vm?
In a bare server side git repository, there is usually a folder called hooks
in there, you can create scripts which's names correspond to certain events in git, like e.g. post-receive. This is fired after the server has received new files from a push event
In my file post-receive, it says this: ```bash
#!/bin/sh
MYDATE="$(date)"
logger "[GIT] Received commit in tuxstash.git on $MYDATE"
ssh username@10.10.10.252 'bash /home/username/tuxstash.sh'```
this basically just starts a script on my raspberry which then proceeds to do it's thing
thank you
also.. how do you do code review on gitlab..
like.. what does Close merge request mean
Sorry, that is not my world :D. All I do is push, pull and the occasional branch.
yeah.. same.. not even the branch.. lol
I'm used a certain other method of source control.. gitlab is new to me
I used SVN back in the day, I still call push a commit
But it is really easy to run your own git service on your server. I run git on my NAS (Network Attached Storage) and all I need to do to set a repo up is git init --bare
thanks a bunch.. you've been a big help
you're welcome ๐
@main olive "close merge request" means that the pull request will be closed without the code in question being merged
so I should add comments against new sections of code being added in merge request and then do what? Is there a button to approve the request or LGTM @main olive
there should be a big button that says "Merge"
what if there are multiple reviewers.. how do I just give my LGTM and let them merge after other reviews
@main olive I assume you're using gitlab from your terminology, so I'm not 100% familiar, but with GitHub you can set a minimum amount of approvals required for anyone to be able to merge
Repository administrators can enforce required reviews so that pull requests must have a specific number of approving reviews before they are merged.
gitlab, respectively: https://docs.gitlab.com/ee/user/project/merge_requests/merge_request_approvals.html
Documentation for GitLab Community Edition, GitLab Enterprise Edition, Omnibus GitLab, and GitLab Runner.
Hello, I made a ubuntu container, and installed python 3.7 on it. But python 3.6 was already on the system, and so when I installed pip3, it installed for py 3.6
What I did to install pip: (I'm root)
apt install python3-pip
And what I've done before to install python3.7:
apt update
apt install software-properties-common
add-apt-repository ppa:deadsnakes/ppa
apt update
apt install python3.7```
I would like to uninstall pip3.6 and install pip for 3.7
This line:
apt install software-properties-common install python3.6
Well all I used was:
pip3 install --upgrade pip and it seems to work now
I'm trying to install the textract package but given all the sub-modules required, it's not easy
Amazing, it works. Sad I didn't make my container persistent.
:( at least you know what to do
Hmm not sure if it goes here but
How do I get whatever I put on a print statement (or well, the proper way, using the logging module) appear on journalctl? Since it doesn't appear at all.
I generally set up logs like:
log = logging.getLogger(__name__)
log.info(...)
Nothing else.
if you're using logging, you generally want to do logging.basicConfig(), or the equivalent, before you start emitting logs
@zinc brook this might interest you https://lincolnloop.com/blog/logging-systemds-journal-python/
Huh interesting, I'll take a look at it. Thanks
I use grep -rnw . -e "some string" quite a lot to search for some string recursively in files... is there anything I'm missing here? Alternatives or whatever
I imagine that works OK
@digital haven I like to use the silver searcher. Some other alternatives are mentioned at the bottom of their page here: https://github.com/ggreer/the_silver_searcher
@digital haven I have that aliased to gh - "grep here"
well, with flags -rni instead
so case doesn't matter and it doesn't try matching a whole word
@main olive that makes sense, cheers
is there a way to supply ttl or something when ssh-ing
my connection keeps getting timed out after a period of inactivity
@main olive https://bjornjohansen.no/ssh-timeout
noice
thanks a bunch
strange.. it says I dont have a config file.. guess I'll make one
configs are good to have, but you can also supply options from the command line with -o
but just stick it in the config
yayy
I have a ssh connexion based on a key, how to disable connexion with passwords?
https://linux.die.net/man/5/sshd_config PasswordAuthentication no in your /etc/ssh/sshd_config
sshd(8) reads configuration data from /etc/ssh/sshd_config (or the file specified with -f on the command line). The file contains keyword-argument pairs, ...
do I need to restart ssh daemon after that?
I got a permission denied with nano ssh_config , so I tried sudo nano ssh_config, and the file has been changed, however I got this message: sudo: unable to resolve host raspberrypi
that means your hostname setting is bad.
arg, is it critical?
What I don't understand is that it changed the file even if there was this message.
it might be just a warning, not an error, not sure. You should still fix it eventually, and make sure /etc/hostname and /etc/hosts are matching.
ok, I'll reload the ssh first
I still got the error/warning, hope it still worked
I think I understand the problem
When accessing directly to the rpm, I'm connected on host "A", but when I'm connecting through ssh, I'm with raspberrypi
I think it's when I configured my ssh connexion, I didn't choose the right user
I followed the guide right there: https://www.raspberrypi.org/documentation/remote-access/ssh/passwordless.md
it may be tricky to do that remotely
I also set LogLevel to VERBOSE to see log attempts
Currently I think I'm connected under the user pi, how to change it?
pam_unix(sshd:session): session opened for user pi
Ok, I found out that I can't connect to user "A" because my key is only for user "pi", and I can't connect through password-connexion
Well then I'll generate a new key...
But I can't stack them in the same file...
Seems like I'll have to use something like that:
Host myshortname realname.example.com
HostName realname.example.com
IdentityFile ~/.ssh/realname_rsa # private key for realname
User remoteusername
Host myother realname2.example.org
HostName realname2.example.org
IdentityFile ~/.ssh/realname2_rsa # different private key for realname2
User remoteusername```
Can I use the same private for multiple users on the same machine?
sure
@frank coral look into SSH agent and agent forwarding
How do you "learn linux" as a dev working in Unix enviroment? (aka = not sysadmin, not developer or OSes). I have Linux Mint installation and i solve problems by googling. Just read through official docs for LM/Ubuntu/Debian?
yeah mostly, using will confront you with enough cases where you have questions to learn it bit by bit
try to understand the things you do, if you follow tutorials or short responses in sites like SO. It was really common to see many years ago instructions that everyone followed and very few understood, such as doing ./configure make make installThis applies to tools related to Python as well
remember your man is a great tool, you should learn how to use it, many times is faster than Google. For example, you can do man source and see what the heck is that that you use for virtualenv... things like that
eh, not so great; better than nothing, though
imo it's a great tool to search for what arguments do what. It's really fast to open it up and type / then -[something], specially when Google doesn't work quite well with that kind of thing
so it says
https://cdn.discordapp.com/attachments/268453833208889345/671705640812675082/unknown.png
do I copy the whole * * * * * bash /home/vidyadhar/autoUnlock & >/dev/null 2>&1 and paste it?
@cobalt kite yes.
changing the username if needed of course
some info about the asterisks if you don't know what they mean
An easy to use editor for crontab schedules.
oops, replace the 4 and 5 on the site with asterisks
@main olive Thank you man!!
I got the thing to work. I read ur message late but thanks
the crontab.guru webpage really helped tho.
no problem dog
@fiery badger linux academy is a good start
Thanks! Never heard of it, but i should give it a look
Hi there, I'm braziliam so I'm sorry for any Spelling mistake, I'm just tryna build a script using python to make tasks easier, but I cant' execute a command with "sudo" I'm using the lib Os -> os.system, I would like to use these commands:
sudo apt-get autoremove -y
sudo apt-get autoclean -y
sudo apt-get clean -y
sudo apt-get update -y
sudo apt-get upgrade -y
This is what happen when I try to use any of them:
sh: sudo: command not found
I hope you understand
those are bash/shell commands, do you really want/need to use python?
I'm a beginner programmer, I've started learning python so It would be good to use python to do this...
Do ya understand?
@vagrant trellis you could use subprocess.run for that, it should prompt for the password in ypur program
!d g subprocess.run
subprocess.run(args, *, stdin=None, input=None, stdout=None, stderr=None, capture_output=False, shell=False, cwd=None, timeout=None, check=False, encoding=None, errors=None, text=None, env=None, universal_newlines=None)```
Run the command described by *args*. Wait for command to complete, then return a [`CompletedProcess`](#subprocess.CompletedProcess "subprocess.CompletedProcess") instance.
The arguments shown above are merely the most common ones, described below in [Frequently Used Arguments](#frequently-used-arguments) (hence the use of keyword-only notation in the abbreviated signature). The full function signature is largely the same as that of the [`Popen`](#subprocess.Popen "subprocess.Popen") constructor - most of the arguments to this function are passed through to that interface. (*timeout*, *input*, *check*, and *capture\_output* are not.)... [read more](https://docs.python.org/3/library/subprocess.html#subprocess.run)
you'll need to separate your aguments in some iterable, if for example you want to run ping -c 2 127.0.0.1 you would call it something like this:python import subprocess subprocess.run(('ping', '-c 2', '127.0.0.1'))
if you go for an alternative (there are), just remember, don't store your password in plain text
sh: sudo: command not found
this sounds like you tried to run your script directly though, such as doing./script.py, without a proper shebang
you can read about it here: https://en.wikipedia.org/wiki/Shebang_(Unix)
you could use #!/usr/bin/env python3
although it also sounds as if you placed a bare sudo in a Python program, so I'm a bit confused
Tank you, but I just found a better way to solve it, I'll share it with you, it may help someone else...
I just used
os.system('comand_here')
and it worked.
sigh
os.system spawns a new shell to run your commands, so it's generally better not to use it and use the functions from the subprocess instead; they are generally safer
not really difference here, though, but subprocess offers many other things that might come handy later, if you want to use it a bit now
why the sigh, @fickle granite?
os.system is one of those things that's easy to use at first, but eventually becomes more trouble than it's worth ... I'd hoped Nieles could have figured out subprocess
well, he's a beginner, as he said - he probably found something that "just worked", and that can be good enough
it's better if you try to make them aware of what the advantages and disadvantages are, than just dropping a sigh
well, sure
dig domain_name +short | whois
this can't be achieved because whois doesnt take output as input
but rather direct command line arguments
does anyone know how to overwrite whois's binary so that i can parse the output of dig onto it as a parameter
im using rn dig domain_name +short | xclip
and then ```
whois xclip -o
which is a lot of hassle
Sounds like you need xargs
@main olive why not cut the xclip middleman, just
whois $(dig domain_name +short)
Oh right that's more ingenious
Hi, I'm sorry if this isn't the right channel but I don't understand much about computers. I want to ask about shell script for mac
Like, I want to create a script for the terminal
And I can't find anything on the syntax
Can I ask here?
Yes
They're called shell scripts
If you're on the latest version of mac OS, your shell is zsh
Here's the manual for that http://zsh.sourceforge.net/Doc/Release/zsh_toc.html
zsh: Table of Contents
Ohh, thank you!
Ok, I'll try to do it now. Thank you so much!
What is that "fi"?
if list then list [ elif list then list ] ... [ else list ] fi
Oh, ok
it's a mirrored if if that's what you're asking
this might help, @main olive http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html. Secion 6, Conditionals, will tell you all about that fi.
Oh, I just assumed it was like "final" or something, haha
Thank you, jeroentbt! I'll look into that
In the meantime, does this make any sense? Because it's not really working...
if networksetup -getairportpower en0 == On then networksetup -setairportpower en0 off [elif networksetup -getairportpower en0 == Off then networksetup -setairportpower en0 on] fi
Also, question: is "zsh" a programming language?
Oh, wait
if [networksetup -getairportpower en0 = On]; then
networksetup -setairportpower en0 off
elif [networksetup -getairportpower en0 = Off]; then
networksetup -setairportpower en0 on]
fi```
Now it doesn't give me an error but it doesn't do anything
I assume networksetup -getairportpower en0 is a command that prints either "On" or "Off"?
I suppose?
If I put that in the terminal it prints out:
Wi-Fi Power (en0): On
Do I have to copy all that?
oh, you use zsh. I'm not familiar with that shell, I mostly know bash. But it should probably be fairly similar.
Anyway, I'm doing this on the Automator app. Perhaps I can ask it to run using bash or something like that?
If it's even possible?
Oh, yes, sorry
I just saw that you can
ok i give up baii
@main olive [ and ] need to be surrounded by spaces (and I recommend using [[
so, like
if [[ $(networksetup -getairportpower en0) = "On" ]]; then
networksetup -setairportpower en0 off
elif [[ $(networksetup -getairportpower en0) = "Off" ]]; then
networksetup -setairportpower en0 on
fi
or even better
STATUS=$(networksetup -getairportpower en0)
if [[ "$STATUS" = "On" ]]; then
networksetup -setairportpower en0 off
elif [[ "$STATUS" = "Off" ]]; then
networksetup -setairportpower en0 on
fi
although I'd use a switch, like so:
CMD="networksetup"
STATUS=$($CMD -getairportpower en0)
case "$STATUS" in
Off)
$CMD -setairportpower en0 on
;;
On)
$CMD -setairportpower en0 off
;;
*)
echo "Unknown status: $STATUS"
;;
esac
@main olive that works, thank you so much!
np dog
@main olive didn't wanna use special characters like ` or )
how are those special characters?
and why so
how did u get venv to work on linux?
:-) 2020-01-30T15:50:06+0000 [ip-10-0-0-79 tmp]$ /usr/bin/python3 -m venv venv
:-) 2020-01-30T15:50:26+0000 [ip-10-0-0-79 tmp]$ ./venv/bin/python --version
Python 3.6.8
:-) 2020-01-30T15:50:32+0000 [ip-10-0-0-79 tmp]$
I like https://virtualenvwrapper.readthedocs.io/. Newbie in Python and this made sense to me. I know it's not venv but I don't think, in the end, there is a difference.
Thanks
What does the code in the answer by 'Or Duan' do?
https://stackoverflow.com/questions/34271982/install-python3-venv-module-on-linux-mint?noredirect=1&lq=1
it sets the locale on your computer
Language settings in Linux (Ubuntu, CentOS). Set (define) locale and language. Add (generate) new locales. Change locale and language settings.
Thanks!
It wants me to do apt-get install python3-venv but I'm not supposed to mess with linux python right? I'll mess up the OS.
is there a way to automatically install all required libraries before running a python script? because i have to try and run my script to get an error, install missing lib and retry. this is going on for about 10 minutes now and its getting harder to find the missing libraries
is there a requirements.txt file?(I'm a noob, so can't help further, sry)
if you mean the script im trying to run. no. thats just one that i made. the problem is importing cv2. it always throws errors for missing libs
It can't be missing python libraries otherwise it wouldn't have been able to install (safe to assume cv2 correctly specified its own dependencies)
If you mean libraries in general then I don't think it is possible when installing via pip
But if you install cv2 using your systems package manager (assuming there is a package on there for cv2) then it should install those libraries
Keep in mind that such an install will only install for the default python that came with the system
im not installing them with pip. Im getting errors like this ImportError: libIlmImf-2_2.so.23: cannot open shared object file: No such file or directory. I installed cv2 with pip3 install opencv-contrib-python and pip3 install opencv-python
I meant installing cv2 with pip, which is exactly what you're doing
You misunderstood me
using raspbian lite btw
What I said was if installing cv2 with pip, it is not possible for pip to automatically install those libraries
ah
makes some sense
so what would be the way to install cv2 with required libraries?
Like I said, you can do it if you install with the system's package manager
Debian has a package https://packages.debian.org/buster/python3-opencv
If you need to install it for a different Python interpreter than raspbian's default, then I think installing this package is still useful because at the least you'll get all the libraries needed.
@lavish badger I don't see a problem with installing it in that way. It is something you want to be available globally. (although I was under the impression that venv is builtin in python3....
@lavish badger jeroen is right, installing python packages with your operating system's package manager is totally safe
as is installing with pip if you use the --user flag or a venv
it's sudo pip which you should never ever do
Yeah jeroen, it's been since v3.3
(sudo -H python3 -m pip preferably though)
@oak shell huh?
I'm not talking about trust, although that's a good point, it's not as vetted
I'm talking about file conflicts with OS package manager managed files
which happens quite a lot if you abuse sudo pip
even when installing as root you should preferably do --user so it gets installed into /root and not the rootfs
nah, you don't get conflicts, at least not on Debian-based systems. ๐คจ
those should be separated in /usr/lib vs /usr/local/lib and dist-packages vs site-packages, although I don't remember the exact details of which go where
they very definitely conflict on arch
yeah
now ls each of those until you find something containing /grub or /boot etc
ls (hd0)
ls (hd0.gpt4)
and so on
Alright I will update you with a pic in a minute
or /efi/grub/boot
are you trying to boot a linux or just getting the Windows bootloader back?
Getting windows bootloader back
oh
in that case just boot from a usb key
but you said the computer does not recognize those at all?
When I boot with windows bootable USB I get this
mmmh looks like the boot medium is damaged
continue to try and ls the hd partitions and see if you find a bootloader. When it works we can try to repair it somehow
maybe #491524019825278977 is more appropriate?
And #491524019825278977 will complain about grub. Stop sending him around channels, it's a mixed issue
@steel verge you still here?
yeah
hd0.gpt2 seems to be the Windows bootloader though
insmod part_gpt
insmod chain
set root=(hd0,gpt2)
chainloader /EFI/Microsoft/Boot/bootmgfw.efi
boot```
try this
If that does not work, try simply typing exit and see if anything comes up
Another method to try is to simply go to the UEFI in the laptop and select the bootloader from there, if that is available
just remembered that, lol
I also found a second USB with windows and it found msdos2
Yes I can boot into UEFI
Look if you can select a different bootloader there
I use the Microsoft Surface Pro 4
should be somewhere under boot
Hmm alright let me see but I will try the commands first
I'd be crazy enough to just launch a pxe env to solve that, but that the WIndows bootloader is totally gone is werid
When I boot from "Ubuntu" it just pushes me to Grub
Yeah, because Grub is the bootloader
What happens if you boot from internal storage?
not sure what they mean with that, never had a surface
Let me ty and boot from internal storage
The device just switches off
I have to turn it on again only to be welcomed by GRUB
can you somehow make a new usb key? or a second one with a live linux or a new Windows iso?
we need to get into recovery
The two USB sticks I have are freshly made Windows ISO bootable USB formatted as NTFS and partitioned as GPT
I made them like 20min ago
ok
my next bet would've been secure boot, but that is disabled
I am out of ideas at this point
Hmm
I could try and make another Linux bootable USB
And we could work from the command line
I mean the Linux terminal
@steel verge
Whether you want to recover access to your unbootable GNU/Linux or you have forgotten your Windows password Rescatux is for you. Use Super Grub2 Disk whenever you cannot boot into any of your systems. Discover all the available rescue options to take in control your machine a...
Look at the middle option
Never used it
Wizards that link to this one Wizard - Restore Grub Introduction This wizard explains step by step how to restore Grub to your machine thanks to Super Grub2
Maybe that helps
Hmm I assume I burn the rescatux iso and attempt to boot from USB normally?
I hope this program is capable of literally wiping all partitions and drives, reformatting them and copying/flashing a bootloader onto them
Bootloaders just sit on the hdd in a separate partition
The part where it says EFI is the bootloader
I haven't used any of those, so I can only guess. They promise to help, if they do we will see
Trying rescatux first
mind detailing your issue so the rest of us can chime in?
@main olive Basically, any usb key won't boot. The Windows bootloader is completely gone, even from the uefi menu
And Grub won't boot either, not even with the command line
Which is weird, because the boot loader from a linux i've installed 2 years ago is still there
Update: I managed to boot a Linux USB with bootloader fixer installed
I selected options to restore MBR, clean and auto setup partitions etc
About to try and boot a windows USB
Update: still error can't boot Windows from USB
@main olive @steel verge
Odd because I can boot any Linux OS
But I can't boot Windows
(from bootable USB of course)
can you boot normally now?
Why do you think debian 9 is giving me this?
and cant find this package
apologises for screenshots, i dont have access to clipboard in vm rn
Because Debian does not provide newer packages very quick, you need another bleeding edge repo probably
hm... damn I didnt know that
Server Distributions rely on sophisticated packages to provide a stable environment
and I suggest you use 3.7
Does this mean they are bad for me to use as a server due to security updates not being updated?
until 3.8 is stable enough for production
No, you are thinking differently about it
I wanted to avoid wrong here
Server systems are in the public space
they need to be secure, newer features are less of a priority
also, stability, as you just said
Do you absolutely need a feature from 3.8?
noper
I just assumed Django would want it and didnt think about this
but it makes sense
Django version Python versions
1.11 2.7, 3.4, 3.5, 3.6, 3.7 (added in 1.11.17)
2.0 3.4, 3.5, 3.6, 3.7
2.1 3.5, 3.6, 3.7
2.2 3.5, 3.6, 3.7, 3.8 (added in 2.2.8)
3.0 3.6, 3.7, 3.8
So, I need a minimum of 3.6 due to security upgrades that are necessary in 3.0 and moving forward
How can i safely add that to the repositories?
If I am going to go this route already, I should just do 3.7 if you would consider it stable
You need to build it
since moving forward
Ok thank you
Ok i need help
Failed to mount '/dev/sdb4': Input/output error
NTFS is inconsistent. Run chkdsk /f on Windows then reboot it TWICE!
The usage of the /f parameter is very IMPORTANT! No modification was
made to NTFS by this software.
Failed to open '/dev/sdb4'.
$MFTMirr does not match $MFT (record 0).
Failed to mount '/dev/sdb4': Input/output error
NTFS is inconsistent. Run chkdsk /f on Windows then reboot it TWICE!
The usage of the /f parameter is very IMPORTANT! No modification was
made to NTFS by this software.
Unable to read the contents of this file system!
Because of this some operations may be unavailable.
The cause might be a missing software package.
The following list of software packages is required for ntfs file system support: ntfs-3g / ntfsprogs.```
Can't mount a partition that was made in windows
ntfs-3g ?
yeah
why doesn't ntfs-3g tell to reboot ?
man i would have saved 2 minutes
i'm trying to use makefiles at the moment and I'm getting a bit confused about how to go about it.
example script
import os
import random
x = [str(random.randint(10,20)) for _ in range(100000)]
with open('one.txt', 'a') as f:
f.write(''.join(x))
with open('two.txt', 'a') as f:
f.write(''.join(x))
example makefile
one.txt : runner.py
python runner.py
two.txt : runner.py
python runner.py
So here I'm expecting this to build files one.txt and two.txt by calling
make at the command line, which it does first time.
If I call make again straight after it says make: 'one.txt' is up to date, which is fine (no mention of two.txt though).
But If I delete two.txt, then re-run make, I get the same message about
make: 'one.txt' is up to date, and it doesn't do anything about two.txt.
So I feel I've done something wrong, or there's something I'm missing.
To recap:
- save above files to dir
- run
make - delete
two.txt - run
make - you will never create
two.txtnow
The first rule in the makefile is the default one
make without arguments will always call only the default rule i.e. the first rule
@warped nimbus no it will call them both if the files don't exist
oh no - because my script outputs both files, so even if only one is called i'll see both ๐คฆ
@warped nimbus i'm a bit confused about how to account for multiple files like this then, as it seems i can only have a single target
one.txt two.txt : runner.py
python runner.py
i tried this, it runs, but i'm able to delete two.txt and never see it again as a result of re-running make
from the docs
The default goal is the target of the first rule in the first makefile. If the first rule has multiple targets, only the first target is taken as the default.
Not sure if there is a way to make it use both targets
you could just define another rule to be the default one
I think this is the right page which explains it https://web.mit.edu/gnu/doc/html/make_9.html#SEC80
all: one.txt two.txt
one.txt two.txt:
python runner.py
.PHONY: all
this seems to work, but i'm not sure how robust it'll be
needing to know the names of all the output files seems to be a bit of a flaw, are there any make alternatives?
i like that it will only compile things once, but it feels a bit clunky
Well you could just make it a phony target
i don't understand - i have a phony year target above and have listed them out
I mean you could just have a single rule that is a phony target
and it will do python runner.py
if all this is doing is providing a check that a file doesn't need compiling why are we still using a 1970s program, seems we could just write a python script for this
and not care about file names
question about uwsgi (and nnginx to run django)... LTS or latest stable release? What is best to go with in something like that?
if you're on linux install the one that comes with your package respository (most likely the LTS) 2.0 @main olive
Debian 9 --
https://uwsgi-docs.readthedocs.io/en/latest/Install.html
So far my experience with debian 9 is that it comes packaged with absolutely nothing and the repo is full of very old version, which is fine for most things. I did have to build python3.7 from source to upgrade from 3.5 though.
According to these instructions I have to build with python or pip, and there are just the two options
LTS means... long term support, and the other is latest stable
what does that really mean?
LTS that is.
With Django what I need is... when vulnerabilities come out, I need the short term upgrade to the next stable version of fixes version.
not oldstable versions like with most tools, right?
and its rapdily moving and growing and changing sort of thing, so i imagine i should just get latest stable BUT
I dont actually know what uwsgi IS.
I know its part of the server stack
Maybe its better to have LTS version of that
it's a thing i need for nginx to work with django, which is a thing I need for my friend to more easily host it for me eventually. Theyre otherwise things I have never set up before.
I mean I can do it, I just want to know the details of what im setting up.
It looks like it is the core of the server, where as nginx is the aspects of serving to the web.
its an applications container.
LTS will have longer support, means the developers will continuously push updates, bug fixes, security patches until the end of the cycle (next LTS release). Latest stable version has newer features, updates, but can contain minor bugs, but no long term support.
Normally debian, ubuntu apt ships most stable one, it seems debian 9 has version 2.0.14 (the latest is 2.0.18) https://packages.debian.org/stretch/uwsgi
But you can install it from pip3 for the most recent version 2.0.18 https://uwsgi-docs.readthedocs.io/en/latest/tutorials/Django_and_nginx.html @main olive
thank you that's a good guide.
But I have one more question. python3 is by default 3.5 which isn't acceptable. I have 3.7 built from source and isntalled as an altinstall. Should i modify python env variables or some such to ensure the correct version is being accessed?
also without thinking I followed the commands for pip install... and got a uWFI install for python2.7 which I should probably remove before i just... use pip3 isntead, and move along?
There seem to be a lot of people clamouring to make 2 and 3 work together but the pages are dated around 2016. Im not sure it's as necessary anymore. I personally dont care about 2.7. If I could tell the machine somehow,
"Please dont use this for any of my stuff.. 2.7 is for your old legacy stuff. Keep it out of my sight."
https://uwsgi-docs.readthedocs.io/en/latest/Python.html#using-the-django-uwsgi-django-app -- this is not necessary is it?
im gonna just try python3.7 -m pip install uwsgi
and see if it knows what to do with that
to make sure it doesnt do the wrong python3
- Yes, make sure the python3.x version you want to use all the time is in the environment variables/
$path - It's better if you remove the python2 uwsgi
pip uninstall uwsgi - python 2 and 3 aren't backward compatible, there could be ways to make them work alongside but that'd not be useful for
uwsgiin this case. Besides python2 has been deprecated already. - It seems
django_uwsgiis needed foruwsgipackage to work withdjango, yes install it too.
@main olive
thanks so much. Already did no. 2. and yeah, even if there were python2 apps I could be serving up, I don't want to as they are probably just vulnerabilities and not going anywhere forward at worst. There are still some useful python2 tools 100%, but... probably not useful python2 web apps to be running lol.
Ive never added anything manually to path before, but I have checked and it seems like it should be in path where it is. Either way. I have set up pipenv very intricately to get the effects I need from any python set up actually.
I do this all the time on my desktop. The only thing is that guides always show virutalenv as the tool being used to activate these envs on these servers.
Hopefully i wont have to switch tools as I am very comfortable with pipenv. I can do pretty much anything with it more easily than other tools.
yeah, its simple enough. You just have to locate the directory where it places the activate script (usually different than the project directory) and use source to activate it same as other tools.
alrioght ty
Unrelated completely...
I have to figure out how to get basic copy and paste functionality from desktop to vm. I have clipboard shared. I am using CTRL + SHIFT + V. I normally do this in GUI vms all the time.
I have tried using xclip but it says that the DISPLAY is null, probably because x11 isnt installed.
What can I do to get copy and paste functionality in this basic interface without installing things i dont need?
I suppose I gotta set up ssh lol. But id rather not. ITs a just a VM on my own machine right in front of me. ideas?
I could write a socket script... but there is a simpler way than that i know
I'm used to the CTRL + SHIFT + V and xclip for complex texts. There's also xsel http://www.vergenet.net/~conrad/software/xsel/
Homepage of Conrad Parker
I did try those things and it just.... in this debian 9 stack with nothing on it for a server, where i literally have to install every tool that i need to use from the ground up, it just doesnt want to work. But...
its all good.
I just made some ssh keys and as simple as that heh.
I just hate having keys everywhere if i dont need them. but i suppose i do
I was gonna say
if you're not installing X on your VM, it's better to run it entirely headless and instead SSH in
With VS Code you can also open a remote folder on your vm via ssh.
but you can work on it like it is on your machine
so no more googling "how do I exit vim?"
๐
or, y'know... git gud :p
Or you can mount a network drive to you server and then mount the same drive to your machine and and Dev using what ever you like on your local
@warm raft you probably want to drop the -e
that's for setting ssh's escape character (read more from the man pages man ssh)
running a command on the remote server requires no flag
SYNOPSIS
ssh [-46AaCfGgKkMNnqsTtVvXxYy] [-B bind_interface] [-b bind_address] [-c cipher_spec]
[-D [bind_address:]port] [-E log_file] [-e escape_char] [-F configfile] [-I pkcs11]
[-i identity_file] [-J destination] [-L address] [-l login_name] [-m mac_spec]
[-O ctl_cmd] [-o option] [-p port] [-Q query_option] [-R address] [-S ctl_path]
[-W host:port] [-w local_tun[:remote_tun]] destination [command]
see last 2 options
it runs differently with -t
its really just some configs i copy/pasted
@white solar how do you like mine? https://asciinema.org/a/3VJZGpg3bAabL3bY3eUEwdi6u
yess
how could i not remember that
who the hell is luke
luke smith
wait, let me guess
arch lover and great talker
yes
ah yeah, it's the guy I was thinking of
i love how everyone kind of knows him
not too fond of him personally as he seems to present misleading information/knowledge often
i love his content
me too
@main olive where for example?
do you know any specific video on where that occurs
as he seems to present misleading information/knowledge often
how so
i was so amazed by the minimalist vim terminal editor he was using all the time that i started learning it back on windows
i don't keep track of it and i've only seen a few of his videos, but i often hear him say "X is an incorrect way of doing Y, you have to do Z instead" about things where X is perfectly valid and has its own reasons that he either doesn't know about or just doesn't care about
i think i saw a video where he ranted how "it makes him mad" when people use cat to pipe files into other commands
this is the one i just thought in my head when you sent the first message
not exactly sure but i think he later said that its not really super bad but to use cat, but for max efficiency you should use <
cat is like muscle memory to me and i dont accidently wipe a file by using > instead of < when i just wanna harmlessly see what's in it
EXACTLY
i agree
i also wrote that as comment on the vid
so, you dont have to agree on every thing he says but i still like to watch his stuff
ok so im gonna try 6ixcord, looks very cool to me
I wouldn't say luke was a great talker.
Very opionated and full of attitude from what I can see.
But defo good at what he does. There is a lot of merit in his works.
But I would think twite before entering a conversation with him
@white solar This is what Linux does.
Allows people to express themselves.
Many people get passionate about a thing and will defend it to the death.
@slender agate start out with sudo apt install python3.8
if it complains about that package not being found you might have to do a sudo apt update
i have 3.8
then do sudo apt install python3-pip
i have pip as well
Oh, you want 3.7 specifically?
ok, looks like you need to use a third party package repository since Ubuntu proper hasn't upgraded from 3.7.5 to 3.7.6 yet
ah damn
you should be able to do that with sudo apt update sudo apt install software-properties-common sudo add-apt-repository ppa:deadsnakes/ppa sudo apt update sudo apt install python3.7
that should get you 3.7.6 from here https://launchpad.net/~deadsnakes/+archive/ubuntu/ppa
after that, you should be able to run it from the command line with python3.7
huh this is wierd
Traceback (most recent call last):
File "/usr/bin/add-apt-repository", line 11, in <module>
from softwareproperties.SoftwareProperties import SoftwareProperties, shortcut_handler
File "/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py", line 28, in <module>
import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'
sudo apt install python-apt first maybe?
Check out this Stack Overflow answer https://stackoverflow.com/a/57147858/5622383
and the one below it that explains why it happens
im getting another error after doing that now
Traceback (most recent call last):
File "/usr/bin/add-apt-repository", line 11, in <module>
from softwareproperties.SoftwareProperties import SoftwareProperties, shortcut_handler
File "/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py", line 67, in <module>
from gi.repository import Gio
File "/usr/lib/python3/dist-packages/gi/__init__.py", line 42, in <module>
from . import _gi
ImportError: cannot import name '_gi' from 'gi' (/usr/lib/python3/dist-packages/gi/__init__.py)
can bash & zsh co-exist in the same machine?
yes
am i correct in assuming most of extra functionalities/ease of use in zsh is often from frameworks like ohmyzsh?
not really
zsh is an entirely different shell
it's "bash-compatible" but still different
oh-my-zsh does have plugin support, but that's separate from the shell itself
The Tools page on our website contains a couple of the most popular tools for programming in Python.
i'd say pick one and try it out. if you like it, keep it. if you don't, try another
this conversation would be more suited for #tools-and-devops though
Thanks, I'll start watching with Pycharm, then I will continue
I personally prefer VS Code, because it simple and slick. PyCharm is mighty and clunky, but powerful. Some things work better there than with VS Code, but you have to really learn it. VS Code is as simple as install and go, figure the rest out while doing it.
Thanks, yes, I worked half a day on Pycharm and itโs really slow and uncomfortable, now Iโll try VS Code.
i think that means u need to create another partition for debian os. or u r trying to install debian on the drive that has already window installed in it
I maded another partition
maybe just try to create a new partion from the remaining space on ur drive c and install it
nvm then haha
And copy linux to it and then install
I will restart and check again
this isn't related to python, we aren't a general tech help server so please don't use the topic channels for this
no
Ok which one?
it's off topic to this entire server, so an off topic channel maybe, but don't feel entitled to assistance on it as it's not what the server is for
no
How are you trying to install it? In WSL or just plain into windows?
I'd really recommend WSL if you need a linux inside your windows
please don't attempt to bring it up again after we've told them to move away from this channel
Why tell him that in the first place? If he tries to get a server up for flask it is on topic
if you'd like to discuss the choice of staff redirecting the convo, you're welcome to dm me since i'm the one that did it, but don't disregard the instruction and continue anyway
Dude, seriously, chill. I just read the issue not the whole conversion.... wtf
BUt you are free to ban for me attempting to help a fella out
it was redirected to an ot channel, you're still able to help them there, i'm just asking you to simply not ressurect it here again.
i haven't given you a warning/infraction over anything either
Well you told him to offtopic and told him there he cant post there either
that is just wrong seriously
way to bully a guy looking for help
because he wants to learn
that's fine, I just don't think this is exactly the best server for it
@orchid steeple: "there's no best ide"
The very beginning on that site:
PyCharm
The very best Python IDE 
But I get what you're saying 
xD didn't notice that
Btw, Is Linux still a good to go OS? I mean, in earlier days it was kind of the special one but with windows 10 now, didn't it become obsolete? I'm kinda familiar with Windows 10 now but still thinking about switching to debian, though I've never tried linux before. Is there any great advantage that you get from using linux or why do you use it?
i'm curious as to why you think linux is obsolete when 95% of servers (for the top 1 million domains) run linux, 85% of phones run linux, 100% of supercomputers run linux, etc
it's more alive than ever and only increasing in popularity
why i use it personally? Windows is a buggy mess and provides me no advantages over what I do, 90% of my job requires using linux, it makes setting up a development environment incredibly easy, is much, much more customisable than windows ever will be, etc
@tidal lark
I didn't know that @main olive. So it is recommended to switching over to Linux, I guess? I've never gone in depth with it and that may be why I had the plain thought of Linux as an obsolete OS.
sources for statistics btw:
recommended?
it depends on what you do and what you want out of your computing experience
if you're the average user who just wants to play games and browse the web, windows is fine for you
if you consider yourself a more tech-savvy computer user, getting familiar with linux is highly recommended
What version are you using? I'm pretty much only using my computer for learning python and later, hopefully, ml. I would like to become more familiar with coding in general, I've come across many coders that are using Linux. I really don't know to what extent I can use either of them and I don't know how to get an overview of it
I personally use Arch on my work laptop, but it's only recommended for users who are already quite familiar with Linux, how it works, and how to set it up
for example, it doesn't provide a graphical interface by default whatsoever
it's up to the user to decide what they want to use and install it
for new users, I've always recommended Kubuntu
it's a version of Ubuntu which comes with the KDE Plasma interface, which is quite nice to use and somewhat similar to the Windows experience
Ubuntu, in turn, is based on Debian
I'm also into GUIs n stuff, I really like having a nice UI experience whatsoever. I've never used the python3 editor but always an IDE
Debian is also good, but it's bland and aims for stability so packages are not updated unless specifically warranted
(or the debian major version is bumped)
I do recommend Kubuntu if a nice UI is your thing
@sage solar which happens like
once a century
So I wouldn't say that I'm really familiar with computers (software and hardware) but I would like to really become more familiar with such
Linux is a good crash course for it then :)
I will try it out on my virtual box
eh, I mean
since 3.1 its being all 2 years
(and yes early debian had minor versions i am amazed myself)
using a VM is a good start if you don't want to replace windows entirely, but... it doesn't often provide a good first impression as VMs are often laggy and the integration isn't as nice
I recommend installing Linux besides Windows on separate partitions, so you can choose whether to boot into windows or linux when starting up your PC
I do have a laptop
And speaking of which, is there a crash course that could fit my "non specified" expectations?
i wouldnt say that linux is coverable by a crash course, it always depends on what you want to do with it
That's what I thought and I don't really have anything in particular for that kind of use. Just want to become more familiar, as already said, but not being employed,(highschool) I haven't yet specified myself. The only thing that I know I want to do is learning machine learning
well then get it yourself and once you wonder how can i do x or whats the best pratice for y ask / google / do a 'man command'
(btw where are the backticks on a us layout?)
right there: `
๐
But I can still use chrome and all that stuff, right? Because I've heard that .exe's are not supported there.
yes linux has their own binary formats
and the majority of software thats not games and not media (photoshop adobe etc) is gonna be on linux
Great !
funnily neough some old windows games are supported by wine (a linux runtime for windows) better than by windows 10
Since when are you using and why did you decide switching to it @sage solar ?
i am now 17 and using linux and OpenBSD since ive been working and uh.......must have been lemme think....
after i was 13
and before i was 15
so
2-3 years i guess
i dont remember why anymore though
Alright, cool. I'm 18 now and just really getting into coding
What are the languages that you're using?
Ah, well, I'm on a python discord server
for private projects im sticking to rust and python mostly.....at work whatever is required so far uhhh:
perl
C
bash/shell scripts
ruby
python
I've got some questions but don't want to flood the channel with it, so could we start a private chat?
feel free to flood the chat while its topic related
and if it isnt feel free to go to ot0-2
I wanted to know what you're mainly doing at your job as I'm about to finish school and don't know if I should apply for a job or go into depth with machine learning at a university
thaats probably ot then
what's the easiest way to get $PWD with ~/ at the start rather than an absolute path
@digital haven why would you even want that? that seems like asking for a solution to an artiffial problem youre maing up to solve something else
@sage solar because i wanted to make the prompt output smaller
if i'm in a few nested dirs it's a bit much, and i don't ever need to see the first couple of dirs
nearly anything is going to be a solution to a problem which isn't exactly what is asked though as, unless you're in the room with me, i kinda have to abstract things a bit to describe them here
so i'm not sure what your point is there @sage solar ๐ค
well in your case i guess thats the actual problem but i cant think of others than UX that would require you to do this so i was guessing you might just be making it difficult for yourself
anyways
im afraid if thats your actual problem i dont think there is a clean way of doing it apart form pattern matching
no, just that the prompt is kinda long, i have the dir and the git repo in the prompt so it can get a bit smushed up
bash is rank
You could try realpath -s --relative-base ~ "$PWD"
-s suppresses symlink lookup, and --relative-base ~ will make it return a relative path (only) if it's inside that base directory, else absolute.
It won't prefix the output with ~/ though. You either get absolute paths starting with / or relative paths inside your home without a leading slash
@oak shell oh, thanks, i'll try. Not having ~/ really doesn't matter ๐ i just thought that might be the most straightforward approach
yes that works ๐
if you do really want the ~/, you could do echo "~/$(realpath -s --relative-base ~ "$PWD")"
no, then it would also apply that to folders outside the home
Anyone know some c?
#include <stdint.h>
#include <stdio.h>
uint64_t THING[] = {51, 52, 53, 54, 55};
void print_len(uint64_t *arr)
{
printf("%lu\n", sizeof(arr));
printf("%lu\n", sizeof(*arr));
}
int main(void)
{
printf("%lu\n", sizeof(THING));
printf("%lu\n", sizeof(*THING));
print_len(THING);
return 0;
}
I'm trying to figure out why this prints
40
8
8
8
Oof, found it
It's just kinda weird that there's all these traps in c and no warnings. Some things are impossible, but it should be possible AFAIK for the compiler to warn when doing sizeof on an array declared in a different scope
This isn't the place to ask for help with C code
Being a Python server and all
You should move the discussion to an off topic channel
C code:/
Hey. I am developing some Sublime Text plugins. I am trying to debug the whole process with pdb but I only get output in Sublime as there is no input for console. I am trying to run Sublime from terminal to get log / feed + console from sublime process but somehow sublime is launched and nothing displayed in terminal. When I lunch any GUI app i usually see all the longs and have session.
Do you know how would I lunch it so that I can debug it with pdb ?
This is sublime lunch script :
$ cat /usr/bin/subl
>>>
#!/bin/sh
exec /opt/sublime_text/sublime_text --fwdargv0 "$0" "$@"
I know that people sometimes have opposite problem when they want to disown or nohup but for me console access is desirable in this case and it doesn't happen by default.
So I can't find help anywhere because usually people are looking for opposite https://askubuntu.com/questions/439187/how-to-open-a-gui-application-and-disconnect-it
Like here.
Solved with remote debugger > https://pypi.org/project/rpdb/0.1.1/
echo "thi sisthat" | grep -E '([[:alpha:]]+ ?)'
This return the string, but it doesn't seem like it should since the ? states a space should be zero or once, but the string has two spaces?
it matches two times
thi (space) and sisthat
as two separate groups
as grep prints the entire line, this will seem like it's one match
try grepping with the -o flag
@full oriole
๐
I have a systemd service that runs docker container, I also have a python service that restarts this container using docker HTTP API when webhook is received.
It looks like sometimes systemd decides that container dies and tries to restart it at the same time.
It results in weird message like Feb 05 17:08:26 vmi335610.contaboserver.net docker[474846]: /bin/docker: Error response from daemon: endpoint with name modbay-worker.service already exists in network bridge.
It happened multiple times already and the only working fix I've found is restarting entire docker daemon.
Can this be fixed somehow? Maybe my setup is wrong and I should not use systemd at all?
if you're managing it with systemd, you shouldn't try to restart it directly
get your webhook to intiate a systemd restart instead
The problem is my python service responsible for webhook processing is also in docker, it has docker socket mounted inside
I guess I'll have to move logic from systemd to my python supervisor
Any suggestions as to why we're timing out when trying to connect to an app hosted on a centos 7.7, running puppet boxes with these ```firewall_rules:
'030 allow all on docker rfc1918':
proto: 'tcp'
action: 'accept'
source: [ '172.16.0.0/12' ]
'050 allow http/https from all':
dport: [ 80, 443 ]
proto: 'tcp'
action: 'accept'
source: [ '129.177.0.0/16' ]
'051 allow 5555':
dport: [ 5555 ]
proto: 'tcp'
action: 'accept'
source: [ '129.177.0.0/16' ]
I'm suspecting it's the os/vm ignoring/blocking requests as there are no logs in the docker containers indicating activity
is there a simple approach to navigating to the project root from a dir? Here the project root contains as .git dir
@digital haven pushd/popd or look into warpdrive
or alias something to cd $(git rev-parse --show-toplevel)
@main olive hmm, I'll need to know it still.
I was thinking of something like
While .git not in is.listdir(): is.chdir(..)
*os
what's wrong with the command I posted?
Is there any tool for linux that will stop the execution of a process, once certain number of lines were printed? I am using subdomain enumeration tools, and sometimes I want to lets say only retrieve 1k subdomains, instead of 20k which will take a long time to finish, so i want the process to be terminated by the time it prints 1000 lines automatically.
head will do that
(yes only prints 5 lines thanks to head and terminates - usually, yes keeps going forever)
@main olive
@main olive thanks, just tested it out
works great combined with tee as well
never really dealt with more than 1 pipeline in 1 command before, but works fine
pipes can get crazy complex
yeah i also just noticed that it's better to put head after the first pipe
getsubdomains google.com | tee -a subdomains | head -n 100 printed out about 120 subdomains instead of 100 cause output gets parsed from tee to head and therefore little delay before the termination
i switched the placement of tee and head and now it does terminate after 100
thanks once again
np dog
or, er, cat
๐คฃ
@main olive oh, nothing sorry i didn't register, that's nice yes ๐
yes | head -n5 i didn't realise space wasn't needed after n
i also didn't realise that i didn't have to write echo yes | head -n 5
@digital haven GNU argument standard states that shorthand flags (ie -n and not --this) don't require spaces before the value, if it takes any
and you can chain shorthand flags together
@main olive so you shouldn't put space?
because it works with both and space reads nicer to me, i guess
they seem different to me - -al is grouping flags, whereas -n 5 is a flag and its argument
that's to me - i'm not saying I'm right there
I think head -vn5 is prettier than head -vn 5
fair, i guess it has the advantage of saving space
it's a matter of taste really
yea, just wondering if there's any recs as it's not something i know much about...if it's pure choice then whatever works i suppose
if you wanna read more about what GNU recommends, https://www.gnu.org/software/libc/manual/html_node/Argument-Syntax.html
Argument Syntax (The GNU C Library)
hrm, i'm always confused with this as i don't think i really care about posix, as i use zsh and stuff (which is for the most part i think? Its just not something i have to be concerned about)
may or may not appear as separate tokens
seems they don't really care either ๐
How can i upgrade my python version on ubuntu? to 8.1
from 3.6.9
look into pyenv
@main olive hi again, head works like a charm, but do you by any chance also know a command that will let the command run for x seconds then terminate it
as in command | wantedtool 10 where i'd want command to be terminated after 10 seconds
off the top of my head, something like this should work
myweirdcommand & PROCID=$!; sleep 10; kill $PROCID
ie run myweirdcommand in the background (operator &), save the last process' PID ($!) as PROCID, sleep for 10 secs, kill the process listed as PROCID
^^ i was thinking of something similar, but forgot the magic var for pid
you might want bg tho idk
actually
much easier
coreutils has timeout built in
timeout 2 yes lets yes run for 2 secs
@main olive timeout 2 yes does work
i was aware of that one
but lmao
I am sooo into pipes rn
it just looks better structurally
you know
anyone knows of a wxPy version that works with Raspbian?
Why do I have multiple instances of the same journalctl and also under root when I don't use the root account?
Well, I did call these journalctl, but was hours ago and under my own user account rather than roo.
but you used sudo
sudo = run as root
(unless you specify another account with -u)
and -f in journalctl means "follow", which leaves the log open until it's SIGINT'd
you can probably just sudo killall journalctl
Hmm I see, I'll do that. For some reason I have some ffmpeg instances running there from my bot when it's not being used.
apparently on fish i can have an alias that'll fill out so that i can search in history and the full command is there, I'm wondering what this is called? As, presumably, there exists such a thing in zsh (which i use)
so i'm wondering if anyone knows what it's called, fish expansion didn't work in google
like in vim you can create abbrevs, ah, that's probably it ha
@somber stirrup sorry - i was asking for this in zshell, thanks though
i have a command that'll take me back to the project root
# nav to the root of a repo
cdr_funct (){
pushd $(git rev-parse --show-toplevel)
clear
}
alias cdr=cdr_funct
What I would like to be able to do is easily navigate back to wherever I was when I entered cdr.
If I enter cdr, then move about a bit, i will have to enter popd a few times to get back to where I was, is there any way around this?
don't think so
you could "cd" instead of "pushd", and then "cd -" to get back
but that only "remembers" "one level"
hard to explain
hrm - problem is i'm often moving around after cdr, and then want to nav back to wherever i was
popd seems like the right thing then
just enter it a few times?
I guess
could be like, 6 or so, hrm
you could have separate shell windows for each directory of interest.
Of course then they wouldn't share history ๐
that sounds like a nightmare
funny how little stuff like this occupies so much of our time (I have my own problems like this, and my own solutions)
i was just thinking that, and convinced myself that it WAS important ๐คฆ
maybe have a few aliases that go straight to whatever directory you want? Assuming you have only a few such directories?
or, use C-r to search for a recent "cd" command, so that you don't have to type it all out?
changes depending on project though, so i can't have fixed. I use C-r, it's nice, but i can't get back like that a lot of the time
the most useful thing I've found is to spend an hour or two sitting next to someone else, while you solve some problem together -- and notice how they do this sort of thing. Everyone seems to do something different, and other people often have interesting techniques that I'd have never thought of on my own
no one else uses stuff like vim so i'd probably end up doing stuff in finder : ' (
ha, I use Emacs, and am similarly lonely ๐
you could probably have an alias or function that takes a number, and pops that many directories. But how on Earth would you know the right number?
To me, it'd be better to have a way of displaying your directory stack, and then just pointing to the entry you want to go to
I've never seen that, but I wouldn't be surprised if zsh has something like that
why will this work in the shell but not as an alias:
echo $(dirs | sed 's/ /\\n/g')
this doesn't work though :
alias x="echo $(dirs | sed 's/ /\\n/g')"
@fickle granite ah, yeah - that's what i'm trying to do here actually ๐
i don't really get why i can't make an alias like this tho
ah - it evaluates ๐คฆ
130 function dirr_funct() {
131 echo $(dirs | sed 's/ /\\n/g')
132 }
133 alias dirr=dirr_funct
that works
echo $(dirs | sed 's/ /\\n/g') | cat -n
๐ค
you don't need an alias if you have a function anyway
ah, fair ๐คฆ
i'm not sure how i'd make the popd function a particular number of times tho
why do you even pass the pipe output to echo anyway?
didn't work without it i dont' think
@digital haven I have never figured out aliases; I use functions exclusively
in fact, here are the first few lines of my .bashrc:
# Many OS's pollute one's shell with weird-ass aliases. I never use
# them.
unalias -a
๐
true story
I use both, in the worst way possible ( as i just learnt )
what do you even want to achieve with this thing?
btw it breaks if your pushed directories contain spaces...
btw it breaks if your pushed directories contain spaces...
yeah, pretty sure i don't have any - i'll just take the hit if i do at any point
i'm not sure how to pass an arg to popd so it'll act a set number of times
I think you want dirs -p (see help dirs)
use the gnu tools if not
or brew install bash (or your favorite shell)
yeah pushd and popd are shell builtins; nothing to do with coreutils
i use zshell
ok, dunno about z
Mac has some ancient bash by default iirc
yeah it sucks - the find tools and stuff are crap as well
those are the bsd versions instead of gnu. not the shell itself
i do have that - i think i've done that command as well
(any thing i should run to check?)
presumably i shouldn't see BSD at the top of things
-> % type -a zsh
zsh is /usr/local/bin/zsh
zsh is /usr/local/bin/zsh
zsh is /usr/local/bin/zsh
zsh is /usr/local/bin/zsh
zsh is /usr/local/bin/zsh
zsh is /usr/local/bin/zsh
zsh is /usr/local/bin/zsh
zsh is /usr/local/bin/zsh
zsh is /usr/local/bin/zsh
zsh is /usr/local/bin/zsh
zsh is /usr/local/bin/zsh
zsh is /usr/local/bin/zsh
zsh is /bin/zsh
wow
๐
your PATH is polluted with duplicates
at least, that's my guess
$ ls -l /usr/local/bin/bash
lrwxr-xr-x 1 brew admin 30 2019-10-01T17:29:11-0700 /usr/local/bin/bash -> ../Cellar/bash/5.0.11/bin/bash*
$
evidence that I'm using bash from homebrew
I have this whole Rube Goldberg script that puts directories on PATH but only if they're not already there. I couldn't believe there wasn't a built-in way to do that, but I never found one, so ... Rube Goldberg it is
i guess i have just put things onto path and the path is in the path so the others are put on again, or something, i'm not sure
export PATH=/usr/local/bin:$PATH:$HOME/bin
export PATH="/usr/local/opt/python/libexec/bin:$PATH"
is that obviously wrong?
i'm not sure why one has quotes now
@fickle granite https://til.hashrocket.com/posts/7evpdebn7g-remove-duplicates-in-zsh-path
not sure if that's of interest to you
sigh Unix kinda sucks, much as I love it
that TIL thing won't work for me because I don't use zsh ๐
well, computers suck in general
ah, yeah - maybe general knowledge though ๐
otoh, that's why they pay us the big bucksยฎ๏ธ
i wasn't sure if there was something more underlying about this PATH thing that you were thinking sucked
i don't really get why it's a hassle... it just is
(to me)
some combination of history, inertia, laziness
and also it's astonishingly hard to write a system like this that is genuinely useful, so most people don't try, and those who try generally fail
bad as Unix is, it's close to the best imaginable
what a scary thought
Microsoft gets points for powershell.
I have never used it, so maybe I'd hate it; but at least they gave it a good try
it probably cost them tens of millions to develop btw
i've heard that powershell is kinda nice, for some things at least
i was tempted to try fish, but couldn't be bothered
zshell seemed like middle ground
I use bash because I'm old and set in my ways
and have a .bashrc that's about one bazillion lines long, and I'm too lazy to "port" it
i think most would just work in zsh, but yeah i can get that
tab completion in zsh is amazing though, i can't leave now
Oh - path is filled each time i source my config
i thought that it would just be replaced
it bugs me that some shells have two path variables. My life isn't complicated enough already?
@digital haven yes, unless you PATH='' anywhere, PATH will most probably be appended instead of replaced
(edit)
sorry, prematurely pressed enter
no worries
@main olive fair - have that command at the end of zshrc now, so i think it's ok
also, yeah, I agree, tab-completion is pretty good
especially with grml
just.. so good
typeset -aU path
139 function pops(){
140 # having output the dir stack i might want to pop back a particular number,
141 # this enables that
142 i=1
143 NUM=$(($1 -1))
144 while [ "$i" -le "$NUM" ]; do
145 clear
146 popd
147 i=$(($i + 1))
148 done
149 clear
150 }
i ended up using this to nav a certain number of dirs down

