#unix

1 messages ยท Page 36 of 1

main olive
#

no.. I'll try that

main olive
#

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

main olive
#

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
main olive
#

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

steel verge
#

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

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

steel verge
#

sudo apt install packagename

#

you can also become root with your user password via sudo -i, if you are in the sudoers file

main olive
#

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

steel verge
#

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"

main olive
#

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
steel verge
#

You need to replace username with an actual username or %u for all users

main olive
#

ahh

steel verge
#

well, %u is the current user

main olive
#

wut

#

I tried replacing with the actual username.. same thing.. command not found

steel verge
#

check where apt lives

#

normally it should be in /usr/bin/apt

main olive
#

yeah looks like it

steel verge
#

Maybe it is the spaces: %u ALL=NOPASSWD:/usr/bin/apt,/usr/bin/aptitude

main olive
#

%u: no such job

steel verge
#

this is weird or I am stupid, because I have lines like this in my /etc/sudoers and it works

main olive
#

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

steel verge
#

You need to add it to your sudoers file

#

/etc/sudoers

main olive
#

hmm still permissions denied

#

I added it

#
%u ALL=NOPASSWD:/usr/bin/apt,/usr/bin/aptitude
steel verge
#

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 ๐Ÿ™‚

main olive
#

great it works

#

I ran as .. sudo apt install

steel verge
#

yeah, now it should run without password

main olive
#

nicee

steel verge
#

anyway, about your connectivity issue: Try to run ping google.com and see if you get a response

main olive
#

I do

steel verge
#

then it is not a routing issue

main olive
#

I'm not sure why it's available externally

steel verge
#

NAT also works fine then

main olive
#

I didnt set up NAT

steel verge
#

no, the gateway does that

main olive
#

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

steel verge
#

Ok can you say again what the issue is there?

#

maybe I misunderstood

main olive
#

it's a private VM (with only an internal IP) on a VPC.. and it's accessible from a bastion host

steel verge
#

VPC = Amazon? What's bastion?

#

Sorry not familiar with aws

main olive
#

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

steel verge
#

But isn't that the point, that you can access your private vm via the bastion server?

main olive
#

yes.. and I can access it

steel verge
#

It shouldn't be accessible from the outside though

#

without connecting to the bastion first

main olive
#

but I'm wondering how the private vm is allowing network traffic to install packages

#

like what route is the traffic taking..

steel verge
#

always to the next gateway

main olive
#

ahh

#

hmm

steel verge
#

Packages are sent to 10.0.254.1 in your case

#

because that is the default route

main olive
#

even though I run the apt install from the private vm?

steel verge
#

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

main olive
#

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

steel verge
#

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

main olive
#

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

steel verge
#

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

main olive
#

i'm using gitlab

#

I have no clue what hook or Nas are

steel verge
#

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.

main olive
#

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?

steel verge
#

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

main olive
#

thank you

#

also.. how do you do code review on gitlab..

#

like.. what does Close merge request mean

steel verge
#

Sorry, that is not my world :D. All I do is push, pull and the occasional branch.

main olive
#

yeah.. same.. not even the branch.. lol

steel verge
#

I am an Admin, not a full time dev ๐Ÿ˜„

main olive
#

I'm used a certain other method of source control.. gitlab is new to me

steel verge
#

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

main olive
#

thanks a bunch.. you've been a big help

steel verge
#

you're welcome ๐Ÿ™‚

main olive
#

@main olive "close merge request" means that the pull request will be closed without the code in question being merged

main olive
#

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

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
#

@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

frank coral
#

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

frank coral
#

Amazing, it works. Sad I didn't make my container persistent.

main olive
#

:( at least you know what to do

zinc brook
#

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.

fickle granite
#

if you're using logging, you generally want to do logging.basicConfig(), or the equivalent, before you start emitting logs

main olive
zinc brook
#

Huh interesting, I'll take a look at it. Thanks

digital haven
#

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

fickle granite
#

I imagine that works OK

fickle sparrow
main olive
#

@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

digital haven
#

@main olive that makes sense, cheers

main olive
#

is there a way to supply ttl or something when ssh-ing

#

my connection keeps getting timed out after a period of inactivity

#

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

frank coral
#

I have a ssh connexion based on a key, how to disable connexion with passwords?

oak shell
frank coral
#

do I need to restart ssh daemon after that?

oak shell
#

reload should be enough, iirc

#

but yeah, it doesn't update automatically

frank coral
#

sudo /etc/init.d/ssh restart is the right command to do so?

oak shell
#

that's old

#

sudo systemctl reload ssh

frank coral
#

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

oak shell
#

that means your hostname setting is bad.

frank coral
#

arg, is it critical?

oak shell
frank coral
#

What I don't understand is that it changed the file even if there was this message.

oak shell
#

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.

frank coral
#

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

#

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?

oak shell
#

sure

main olive
#

@frank coral look into SSH agent and agent forwarding

fiery badger
#

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?

south star
#

yeah mostly, using will confront you with enough cases where you have questions to learn it bit by bit

tall coyote
#

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

fickle granite
#

eh, not so great; better than nothing, though

tall coyote
#

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

fickle granite
#

that's all entirely correct.

#

but ... sigh

cobalt kite
main olive
#

@cobalt kite yes.

#

changing the username if needed of course

#

some info about the asterisks if you don't know what they mean

#

oops, replace the 4 and 5 on the site with asterisks

cobalt kite
#

@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.

main olive
#

no problem dog

cunning skiff
#

@fiery badger linux academy is a good start

fiery badger
#

Thanks! Never heard of it, but i should give it a look

vagrant trellis
#

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

edgy minnow
#

those are bash/shell commands, do you really want/need to use python?

vagrant trellis
#

I'm a beginner programmer, I've started learning python so It would be good to use python to do this...

#

Do ya understand?

tall coyote
#

@vagrant trellis you could use subprocess.run for that, it should prompt for the password in ypur program

#

!d g subprocess.run

shy yokeBOT
#
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)
tall coyote
#

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 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

vagrant trellis
#

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.

fickle granite
#

sigh

tall coyote
#

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?

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

tall coyote
#

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

fickle granite
#

well, sure

main olive
#

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

warped nimbus
#

Sounds like you need xargs

main olive
#

@main olive why not cut the xclip middleman, just

whois $(dig domain_name +short)
warped nimbus
#

Oh right that's more ingenious

main olive
#

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?

warped nimbus
#

Yes

#

They're called shell scripts

#

If you're on the latest version of mac OS, your shell is zsh

main olive
#

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

warped nimbus
#

That's just how the syntax is

#

fi is always at the end

main olive
#

Oh, ok

tall coyote
#

it's a mirrored if if that's what you're asking

fickle sparrow
main olive
#

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

oak shell
#

I assume networksetup -getairportpower en0 is a command that prints either "On" or "Off"?

main olive
#

I suppose?

#

If I put that in the terminal it prints out:

#

Wi-Fi Power (en0): On

#

Do I have to copy all that?

oak shell
#

oh, you use zsh. I'm not familiar with that shell, I mostly know bash. But it should probably be fairly similar.

main olive
#

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
#

@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
main olive
#

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
#

@main olive that works, thank you so much!

main olive
#

np dog

main olive
#

@main olive didn't wanna use special characters like ` or )

#

how are those special characters?

#

and why so

lavish badger
#

how did u get venv to work on linux?

fickle granite
#
:-) 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]$ 
fickle sparrow
lavish badger
#

Thanks

fickle sparrow
#

it sets the locale on your computer

lavish badger
#

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.

strong hedge
#

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

lavish badger
#

is there a requirements.txt file?(I'm a noob, so can't help further, sry)

strong hedge
#

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

warped nimbus
#

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

strong hedge
#

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

warped nimbus
#

I meant installing cv2 with pip, which is exactly what you're doing

strong hedge
#

thats what i did

#

but i just get them errors

#

and i got python 3.7 with os install

warped nimbus
#

You misunderstood me

strong hedge
#

using raspbian lite btw

warped nimbus
#

What I said was if installing cv2 with pip, it is not possible for pip to automatically install those libraries

strong hedge
#

ah

#

makes some sense

#

so what would be the way to install cv2 with required libraries?

warped nimbus
#

Like I said, you can do it if you install with the system's package manager

#

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.

strong hedge
#

ill give it a try

#

ayy more ImportErrors

#

im fcking done with this

fickle sparrow
#

@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....

main olive
#

@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

oak shell
#

not really

#

if you trust the packages, it's sometimes even necessary

vestal turret
#

Yeah jeroen, it's been since v3.3

oak shell
#

(sudo -H python3 -m pip preferably though)

main olive
#

@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

oak shell
#

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

main olive
#

they very definitely conflict on arch

mossy sleet
#

@steel verge

steel verge
#

yeah

#

now ls each of those until you find something containing /grub or /boot etc

#

ls (hd0)

#

ls (hd0.gpt4)

#

and so on

mossy sleet
#

Alright I will update you with a pic in a minute

steel verge
#

or /efi/grub/boot

#

are you trying to boot a linux or just getting the Windows bootloader back?

mossy sleet
#

Getting windows bootloader back

steel verge
#

oh

#

in that case just boot from a usb key

#

but you said the computer does not recognize those at all?

mossy sleet
steel verge
#

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

main olive
steel verge
#

And #491524019825278977 will complain about grub. Stop sending him around channels, it's a mixed issue

mossy sleet
#

@steel verge you still here?

steel verge
#

yeah

mossy sleet
#

Simply nothing

steel verge
#

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

mossy sleet
steel verge
#

that seems to be a cd rom

#

Can you boot into UEFI?

#

some call it bios

mossy sleet
#

Yes I can boot into UEFI

steel verge
#

Look if you can select a different bootloader there

mossy sleet
#

I use the Microsoft Surface Pro 4

steel verge
#

should be somewhere under boot

mossy sleet
#

Hmm alright let me see but I will try the commands first

steel verge
#

I'd be crazy enough to just launch a pxe env to solve that, but that the WIndows bootloader is totally gone is werid

mossy sleet
#

When I boot from "Ubuntu" it just pushes me to Grub

steel verge
#

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

mossy sleet
#

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

steel verge
#

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

mossy sleet
#

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

steel verge
#

ok

#

my next bet would've been secure boot, but that is disabled

#

I am out of ideas at this point

mossy sleet
#

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

steel verge
#

Look at the middle option

#

Never used it

#

Maybe that helps

mossy sleet
#

Hmm I assume I burn the rescatux iso and attempt to boot from USB normally?

steel verge
#

worth a try

#

or Super Grub2 Disk. But I guess any will help or not

mossy sleet
#

I hope this program is capable of literally wiping all partitions and drives, reformatting them and copying/flashing a bootloader onto them

steel verge
#

Bootloaders just sit on the hdd in a separate partition

mossy sleet
#

Do you think this could also help?

steel verge
#

I haven't used any of those, so I can only guess. They promise to help, if they do we will see

mossy sleet
#

Trying rescatux first

main olive
#

mind detailing your issue so the rest of us can chime in?

steel verge
#

@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

main olive
#

grub seems to be booting, though?

#

just missing a config

mossy sleet
#

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)

steel verge
#

can you boot normally now?

main olive
#

apologises for screenshots, i dont have access to clipboard in vm rn

steel verge
#

Because Debian does not provide newer packages very quick, you need another bleeding edge repo probably

main olive
#

hm... damn I didnt know that

steel verge
#

Server Distributions rely on sophisticated packages to provide a stable environment

#

and I suggest you use 3.7

main olive
#

Does this mean they are bad for me to use as a server due to security updates not being updated?

steel verge
#

until 3.8 is stable enough for production

main olive
#

mm

#

Okay so

#

What do I need to run Django?

#

Do you know offhand?

steel verge
#

No, you are thinking differently about it

#

I wanted to avoid wrong here

#

Server systems are in the public space

main olive
#

That makes sense.

#

about stability

steel verge
#

they need to be secure, newer features are less of a priority

#

also, stability, as you just said

main olive
#

Makes sense, totally.

#

All I need is whatever Django needs then, let me find out

steel verge
#

Do you absolutely need a feature from 3.8?

main olive
#

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

steel verge
#

You need to build it

main olive
#

since moving forward

steel verge
main olive
#

Ok thank you

main olive
#

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

uneven silo
#

uh yeah linux doesn't have native ntfs support

#

install ntfs-3g like it says

main olive
#

ntfs-3g ?

#

yeah

#

why doesn't ntfs-3g tell to reboot ?
man i would have saved 2 minutes

digital haven
#

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.txt now
warped nimbus
#

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

digital haven
#

@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

warped nimbus
#

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

digital haven
#
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

warped nimbus
#

Well you could just make it a phony target

digital haven
#

i don't understand - i have a phony year target above and have listed them out

warped nimbus
#

I mean you could just have a single rule that is a phony target

#

and it will do python runner.py

digital haven
#

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

warped nimbus
#

and not care about file names

main olive
#

question about uwsgi (and nnginx to run django)... LTS or latest stable release? What is best to go with in something like that?

fallen silo
#

if you're on linux install the one that comes with your package respository (most likely the LTS) 2.0 @main olive

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.

fallen silo
#

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

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."

#

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

fallen silo
#
  1. Yes, make sure the python3.x version you want to use all the time is in the environment variables/$path
  2. It's better if you remove the python2 uwsgi pip uninstall uwsgi
  3. python 2 and 3 aren't backward compatible, there could be ways to make them work alongside but that'd not be useful for uwsgi in this case. Besides python2 has been deprecated already.
  4. It seems django_uwsgi is needed for uwsgi package to work with django, yes install it too.
    @main olive
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

main olive
#

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

fallen silo
main olive
#

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

main olive
#

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

steel verge
#

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?"

#

๐Ÿ˜›

main olive
#

or, y'know... git gud :p

cunning skiff
#

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
main olive
#

@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

warm raft
#

oh wow, i thought it was exec, why is it t and not e

#

oh rly

main olive
#
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

warm raft
main olive
#

-t allocates a pseudoterminal

#

ie emulates a tty

white solar
#

i really like that terminal setup you got going there @warm raft

#

arch?

warm raft
#

its really just some configs i copy/pasted

main olive
warm raft
white solar
#

definitely better than mine :p

#

ooooh

#

that's luke's setup

warm raft
#

yess

white solar
#

how could i not remember that

warm raft
#

absolutely loving i3 and all

#

started using stuff like this like a few months ago

white solar
#

i tried installing arch once

#

said noone ever

main olive
#

who the hell is luke

warm raft
#

luke smith on yt

white solar
#

luke smith

main olive
#

wait, let me guess

white solar
#

arch lover and great talker

warm raft
#

yes

main olive
#

ah yeah, it's the guy I was thinking of

warm raft
#

i love how everyone kind of knows him

main olive
#

not too fond of him personally as he seems to present misleading information/knowledge often

white solar
#

i love his content

warm raft
#

me too

#

@main olive where for example?

#

do you know any specific video on where that occurs

white solar
#

as he seems to present misleading information/knowledge often
how so

warm raft
#

i was so amazed by the minimalist vim terminal editor he was using all the time that i started learning it back on windows

main olive
#

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

warm raft
#

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

main olive
#

EXACTLY

white solar
#

i agree

warm raft
#

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

white solar
#

although, topic of linux on yt is a very wild place

#

a lot of rants

cunning skiff
#

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.

vast topaz
#

@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

slender agate
#

i have 3.8

vast topaz
#

then do sudo apt install python3-pip

slender agate
#

i have pip as well

vast topaz
#

Oh, you want 3.7 specifically?

slender agate
#

yeh

#

3.7.6

#

i cant find anyway to install it directly

vast topaz
#

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

slender agate
#

ah damn

vast topaz
#

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

#

after that, you should be able to run it from the command line with python3.7

slender agate
#

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'
vast topaz
#

sudo apt install python-apt first maybe?

slender agate
#

nope

#

same thing

vast topaz
#

and the one below it that explains why it happens

slender agate
#

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)
ocean bay
#

can bash & zsh co-exist in the same machine?

uneven silo
#

yes

ocean bay
#

am i correct in assuming most of extra functionalities/ease of use in zsh is often from frameworks like ohmyzsh?

uneven silo
#

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

solid drift
#

Hi, what is the best IDE for Python on Linux?

orchid steeple
#

there's no best ide

#

it's all based on preference

#

!tools

shy yokeBOT
#
Tools

The Tools page on our website contains a couple of the most popular tools for programming in Python.

orchid steeple
#

i'd say pick one and try it out. if you like it, keep it. if you don't, try another

solid drift
#

Thanks, I'll start watching with Pycharm, then I will continue

steel verge
#

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.

solid drift
#

Thanks, yes, I worked half a day on Pycharm and itโ€™s really slow and uncomfortable, now Iโ€™ll try VS Code.

main olive
#

Hello guys

#

Got this Problem
Any one that can help?

frozen lodge
#

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

main olive
#

I maded another partition

frozen lodge
#

maybe just try to create a new partion from the remaining space on ur drive c and install it

#

nvm then haha

main olive
#

And copy linux to it and then install

frozen lodge
#

ye

#

or just us vm

#

i installed it on external drive lol

main olive
#

I will restart and check again

sharp shell
#

this isn't related to python, we aren't a general tech help server so please don't use the topic channels for this

main olive
#

Still not working

#

Ok

#

Can i use this one?

sharp shell
#

no

main olive
#

Ok which one?

sharp shell
#

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

main olive
#

K Can u help me in dm than

#

Please

sharp shell
#

no

steel verge
#

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

sharp shell
#

please don't attempt to bring it up again after we've told them to move away from this channel

steel verge
#

Why tell him that in the first place? If he tries to get a server up for flask it is on topic

sharp shell
#

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

steel verge
#

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

sharp shell
#

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

steel verge
#

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

main olive
#

that's fine, I just don't think this is exactly the best server for it

tidal lark
#

@orchid steeple: "there's no best ide"

The very beginning on that site:
PyCharm
The very best Python IDE finger_gun

#

But I get what you're saying xd

orchid steeple
#

xD didn't notice that

tidal lark
#

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?

main olive
#

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

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.

main olive
#

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

tidal lark
#

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

main olive
#

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

tidal lark
#

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

main olive
#

Debian is also good, but it's bland and aims for stability so packages are not updated unless specifically warranted

sage solar
#

(or the debian major version is bumped)

main olive
#

I do recommend Kubuntu if a nice UI is your thing

#

@sage solar which happens like

#

once a century

tidal lark
#

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

sage solar
#

nah

#

usually happens all 2 years

main olive
#

Linux is a good crash course for it then :)

tidal lark
#

I will try it out on my virtual box

main olive
#

eh, I mean

sage solar
#

since 3.1 its being all 2 years

#

(and yes early debian had minor versions i am amazed myself)

main olive
#

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

tidal lark
#

I do have a laptop

#

And speaking of which, is there a crash course that could fit my "non specified" expectations?

sage solar
#

i wouldnt say that linux is coverable by a crash course, it always depends on what you want to do with it

tidal lark
#

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

sage solar
#

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?)

tidal lark
#

right there: `

sage solar
#

๐Ÿ™„

tidal lark
#

I'll give Kubuntu a try then, thx

sage solar
#

aaaah

#
test
#

now....where is that key on a 60% layout....

tidal lark
#

But I can still use chrome and all that stuff, right? Because I've heard that .exe's are not supported there.

sage solar
#

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

tidal lark
#

Great !

sage solar
#

funnily neough some old windows games are supported by wine (a linux runtime for windows) better than by windows 10

tidal lark
#

Since when are you using and why did you decide switching to it @sage solar ?

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

tidal lark
#

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

sage solar
#

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

tidal lark
#

I've got some questions but don't want to flood the channel with it, so could we start a private chat?

sage solar
#

feel free to flood the chat while its topic related

#

and if it isnt feel free to go to ot0-2

tidal lark
#

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

sage solar
#

thaats probably ot then

digital haven
#

what's the easiest way to get $PWD with ~/ at the start rather than an absolute path

sage solar
#

@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

digital haven
#

@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 ๐Ÿค”

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

digital haven
#

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

oak shell
#

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

digital haven
#

@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 ๐Ÿ‘

main olive
#

if you do really want the ~/, you could do echo "~/$(realpath -s --relative-base ~ "$PWD")"

oak shell
#

no, then it would also apply that to folders outside the home

main olive
#

oh yeah

#

sorry i'm very tipsy rn

umbral tulip
#

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

uneven silo
#

yea

#
array
pointer
pointer
pointer to pointer
umbral tulip
#

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

uneven silo
#

its not a trap

#

how should it know what you meant

#

also, how did you compile it?

warped nimbus
#

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

solid drift
#

C code:/

regal stump
#

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.

#

Like here.

regal stump
full oriole
#

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?

main olive
#

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

full oriole
#

Ah. Got it.

#

yep. Thanks @main olive

main olive
#

๐Ÿ‘

split pulsar
#

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?

main olive
#

if you're managing it with systemd, you shouldn't try to restart it directly

#

get your webhook to intiate a systemd restart instead

split pulsar
#

The problem is my python service responsible for webhook processing is also in docker, it has docker socket mounted inside

split pulsar
#

I guess I'll have to move logic from systemd to my python supervisor

deft raft
#

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

digital haven
#

is there a simple approach to navigating to the project root from a dir? Here the project root contains as .git dir

main olive
#

@digital haven pushd/popd or look into warpdrive

#

or alias something to cd $(git rev-parse --show-toplevel)

digital haven
#

@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

main olive
#

what's wrong with the command I posted?

main olive
#

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

minor ferry
#

๐Ÿคฃ

digital haven
#

@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

main olive
#

@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

digital haven
#

@main olive so you shouldn't put space?

#

because it works with both and space reads nicer to me, i guess

main olive
#

you can, just as you can write ls -a -l instead of ls -al

#

but you don't have to

digital haven
#

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

main olive
#

I think head -vn5 is prettier than head -vn 5

digital haven
#

fair, i guess it has the advantage of saving space

main olive
#

it's a matter of taste really

digital haven
#

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

main olive
digital haven
#

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 ๐Ÿ˜„

main olive
#

it just means both are acceptable

#

what you use is up to preference :)

static mountain
#

How can i upgrade my python version on ubuntu? to 8.1
from 3.6.9

main olive
#

look into pyenv

main olive
#

@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

uneven silo
#

^^ i was thinking of something similar, but forgot the magic var for pid

#

you might want bg tho idk

main olive
#

actually

#

much easier

#

coreutils has timeout built in

#

timeout 2 yes lets yes run for 2 secs

uneven silo
#

the above does work

#

can confirm

#

both work

main olive
#

@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

dusty basalt
#

anyone knows of a wxPy version that works with Raspbian?

zinc brook
#

Why do I have multiple instances of the same journalctl and also under root when I don't use the root account?

main olive
#

@zinc brook who called them?

#

pstree -hp

zinc brook
#

Well, I did call these journalctl, but was hours ago and under my own user account rather than roo.

main olive
#

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

zinc brook
#

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.

digital haven
#

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
digital haven
#

@somber stirrup sorry - i was asking for this in zshell, thanks though

digital haven
#

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?

fickle granite
#

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

digital haven
#

hrm - problem is i'm often moving around after cdr, and then want to nav back to wherever i was

fickle granite
#

popd seems like the right thing then

digital haven
#

just enter it a few times?

fickle granite
#

I guess

digital haven
#

could be like, 6 or so, hrm

fickle granite
#

you could have separate shell windows for each directory of interest.

#

Of course then they wouldn't share history ๐Ÿ˜

digital haven
#

that sounds like a nightmare

fickle granite
#

funny how little stuff like this occupies so much of our time (I have my own problems like this, and my own solutions)

digital haven
#

i was just thinking that, and convinced myself that it WAS important ๐Ÿคฆ

fickle granite
#

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?

digital haven
#

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

fickle granite
#

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

digital haven
#

no one else uses stuff like vim so i'd probably end up doing stuff in finder : ' (

fickle granite
#

ha, I use Emacs, and am similarly lonely ๐Ÿ™‚

digital haven
#

I'm going for

alias p1="popd"
alias p2="popd;popd"

๐ŸŒš

#

etc

fickle granite
#

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

digital haven
#

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

๐Ÿค”

oak shell
#

you don't need an alias if you have a function anyway

digital haven
#

ah, fair ๐Ÿคฆ

#

i'm not sure how i'd make the popd function a particular number of times tho

oak shell
#

why do you even pass the pipe output to echo anyway?

digital haven
#

didn't work without it i dont' think

fickle granite
#

@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
digital haven
#

๐Ÿ˜„

fickle granite
#

true story

digital haven
#

I use both, in the worst way possible ( as i just learnt )

oak shell
#

what do you even want to achieve with this thing?

#

btw it breaks if your pushed directories contain spaces...

digital haven
#

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

oak shell
#

I think you want dirs -p (see help dirs)

digital haven
#

idk if i have that on osx

#

it's not in the man page at least

fickle granite
#

use the gnu tools if not

oak shell
#

also popd understands +N and -N (N being a number)

#

help popd

fickle granite
#

or brew install bash (or your favorite shell)

#

yeah pushd and popd are shell builtins; nothing to do with coreutils

oak shell
#

but yeah, that's Ubuntu / bash 4.3

#

Mac has some ancient bash by default iirc

digital haven
#

i use zshell

oak shell
#

ok, dunno about z

digital haven
#

Mac has some ancient bash by default iirc
yeah it sucks - the find tools and stuff are crap as well

oak shell
#

those are the bsd versions instead of gnu. not the shell itself

fickle granite
#

homebrew to the rescue

#

can't use a mac without it, imho

digital haven
#

i do have that - i think i've done that command as well

#

(any thing i should run to check?)

fickle granite
#

type -a zsh

#

although ... that might not work in zsh ๐Ÿ™‚

digital haven
#
-> % 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
fickle granite
#

wow

digital haven
#

๐Ÿ™ƒ

fickle granite
#

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

digital haven
#

hrm yeah it really is

#

i just ran echo $PATH

fickle granite
#

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

digital haven
#

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
#

sigh Unix kinda sucks, much as I love it

digital haven
#

:<

#

this path stuff specifically?

fickle granite
#

that TIL thing won't work for me because I don't use zsh ๐Ÿ™‚

#

well, computers suck in general

digital haven
#

ah, yeah - maybe general knowledge though ๐Ÿ™ƒ

fickle granite
#

otoh, that's why they pay us the big bucksยฎ๏ธ

digital haven
#

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)

fickle granite
#

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

digital haven
#

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

fickle granite
#

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

digital haven
#

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

fickle granite
#

it bugs me that some shells have two path variables. My life isn't complicated enough already?

main olive
#

@digital haven yes, unless you PATH='' anywhere, PATH will most probably be appended instead of replaced

digital haven
#

(edit)

main olive
#

sorry, prematurely pressed enter

digital haven
#

no worries

#

@main olive fair - have that command at the end of zshrc now, so i think it's ok

main olive
#

also, yeah, I agree, tab-completion is pretty good

#

especially with grml

#

just.. so good

digital haven
#
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