#unix

1 messages Β· Page 30 of 1

gritty stirrup
#

udo: unable to execute /usr/local/bin/sharpops: No such file or directory

#

Huh

#

What am I running>?

sage solar
#

a thing that should tell us what this lib is linking against

gritty stirrup
#

lid sharpops

sage solar
#

whats lid lol

gritty stirrup
#

lld

#

the fuck is this

sage solar
#

lld is a utility for listing what a binary links against

gritty stirrup
#

I don't have it

#

I can't install it

sage solar
#

oh its ldd

#

woopsie

gritty stirrup
#

FUCK YOU

sage solar
#

what

gritty stirrup
#
adam@vmi261078:/usr/local/bin$ ldd sharpops
        linux-vdso.so.1 (0x00007fffcc563000)
        libc.musl-x86_64.so.1 => not found
#
sudo rm -r /usr/local/bin/sharpops /usr/local/bin/sharpops-data
sudo rm /etc/systemd/system/sharpops.service
sudo systemctl daemon-reload

# Download and unpack
wget https://github.com/Sharpz7/sharp-ops/releases/download/XXXXX/linux.tar.gz
sudo tar -C /usr/local/bin/ -zxvf linux.tar.gz
rm -r linux.tar.gz

# Create Sharpops User
if $(grep -c '^sharpops:' /etc/passwd) == 0; then
    sudo useradd sharpops
    sudo groupadd docker
    sudo usermod -aG docker sharpops
    sudo systemctl restart docker
fi

# Permissions
sudo chown adam:adam /usr/local/bin/sharpops
chmod u+x /usr/local/bin/sharpops
chmod 755 /usr/local/bin/sharpops
sudo chown -R sharpops:sharpops /usr/local/bin/sharpops-data
#

I'm running this

sage solar
#

why does it link against musl

gritty stirrup
#

But I can't see what here would be breaking it

sage solar
#

install the musl libc then

gritty stirrup
#

tar?

sage solar
#

install muscl libc

gritty stirrup
#

This was working up untill I tried to change shit

sage solar
#

IT IS ALPINE

#

YOURE running alpine

#

arent you

gritty stirrup
#

No

#

Wait

#

I build the image on alpine

sage solar
#

AHA

#

there you have it

#

alpine doesnt link against GNU libc but muscl libc

gritty stirrup
#

So the executable is missing shit?

sage solar
#

and most linux systems wants GNU libc

gritty stirrup
#

That's soooooo stupid

#

Thanks!

sage solar
#

thats minimization

gritty stirrup
#

Its GAY

#

@sage solar 2 circleci builds later, and it works

#

ty!

#

nix's useless unix trivia ftw

sage solar
#

πŸ™‚ 😦

warped nimbus
#

not useless

#

It's also the reason why manylinux wheels do not work on Alpine

#

😭

torn snow
#

For some added context

#

The reason is that you can't statically link glibc easily, because it's rather big and also won't be fully statically linked if you call any hostname- or passwd-related functions

#

Because those are extensible via authentication mechanisms that can be extended at runtime

#

So they have to be loaded dynamically

#

Therefore glibc is linked dynamically, but as a result binaries that link it dynamically won't run on musl systems

sage solar
#

Except that in this case it's the other way round and alpine linked musl libc against the binary and thus it won't run on glibc systems

torn snow
#

LMAO I read it backwards

#

I guess that's actually an easier fix, just statically link libc?

#

I mean Alpine is pretty much the best OS for static binaries

main olive
#

Ok, I don't even know if this is the right place to ask help for this but. I've been having a problem setting up deoplete in neovim

#

I don't know if it's because of anaconda or something else

#

It says, "deoplete requires nvim 0.3.0+"

sage solar
#

@main olive and what nvim version have you got?

main olive
#
Collecting neovim
Collecting pynvim>=0.3.1 (from neovim)
Collecting greenlet (from pynvim>=0.3.1->neovim)
  Using cached https://files.pythonhosted.org/packages/bf/45/142141aa47e01a5779f0fa5a53b81f8379ce8f2b1cd13df7d2f1d751ae42/greenlet-0.4.15-cp36-cp36m-manylinux1_x86_64.whl
Collecting msgpack>=0.5.0 (from pynvim>=0.3.1->neovim)
  Using cached https://files.pythonhosted.org/packages/92/7e/ae9e91c1bb8d846efafd1f353476e3fd7309778b582d2fb4cea4cc15b9a2/msgpack-0.6.1-cp36-cp36m-manylinux1_x86_64.whl
Installing collected packages: greenlet, msgpack, pynvim, neovim
Successfully installed greenlet-0.4.15 msgpack-0.6.1 neovim-0.3.1 pynvim-0.3.2
sage solar
#

Except that that is the python neovim package and not neovim itself

#

That's not your neovim version

main olive
#

How do I find out my neovim version?

#

Sorry, I'm new to using vim

sage solar
#

Probably nvim --version

main olive
#

Ok

#
nvim --version
NVIM v0.2.2
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/cc -g -O2 -fdebug-prefix-map=/build/neovim-_mzR4z/neovim-0.2.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -DDISABLE_LOG -Wdate-time -D_FORTIFY_SOURCE=2 -Wconversion -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -O2 -g -DMIN_LOG_LEVEL=3 -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -I/build/neovim-_mzR4z/neovim-0.2.2/build/config -I/build/neovim-_mzR4z/neovim-0.2.2/src -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/build/neovim-_mzR4z/neovim-0.2.2/build/src/nvim/auto -I/build/neovim-_mzR4z/neovim-0.2.2/build/include
Compiled by pkg-vim-maintainers@lists.alioth.debian.org

Features: +acl +iconv +jemalloc +tui 
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/share/nvim"

Run :checkhealth for more info
sage solar
#

Well there is your issue

main olive
#

Yeah. Just figured it out

#

I thought it was the neovim in python

#

Thank you. I was stuck on this for like 3 days

sage solar
#

Haha no problem

split pulsar
#

How do I make systemd restart my app every N seconds if it fails?
Currently it tries to restart it like 5 times in a row and if it fails, I have to restart it manually

#

My app updates itself using git so syntax error or config error can happen, that's why app can start exiting with error until I push fix

wraith jasper
#

i need some help on linux... i tried importing newly installed modules but they didn't get imported at first

#

i managed to fix these problems... anyways i can't manage to get tkinter imported for some reason

#

nvm i guess there is a glitch with the atom package

wraith jasper
#

hmmmmm

#

i would need help

#

so i tried this script if it works (this is just an example)

import sys
sys.path.append('/home/matej/.local/lib/python3.7/site-packages')#keyboard module
import time
import keyboard
def func(key):
    print('key ' + key + ' pressed')
keyboard.add_hotkey('ctrl + alt + Z', lambda: func('Z'))
keyboard.add_hotkey('ctrl + alt + X', lambda: func('X'))
keyboard.add_hotkey('ctrl + alt + S', lambda: func('S'))
# keyboard.add_hotkey('ctrl + alt + D', lambda: func('D'))
# keyboard.add_hotkey('ctrl + alt + M', lambda: func('M'))
# keyboard.add_hotkey('ctrl + alt + U', lambda: func('U'))
# keyboard.add_hotkey('ctrl + alt + O', lambda: func('O'))
time.sleep(100)
#

the reason that i had to comment last 4 hotkeys is that they cause an error for some reason

#

here is the error that is shown when the last 4 hotkeys aren't commented

torn snow
#

@wraith jasper FYI you shouldn't have to do the sys.path.append at the top

#

Make sure you didn't mix up multiple python versions

#

Because trust me from experience, once your install gets messed up it only ever gets worse...

wraith jasper
#

thnx for the advice

potent orchid
#

HI! Im new to all this and Im trying to install Anaconda on Linux at the moment. But I get the following message after installation:

Preparing transaction: done
Executing transaction: / WARNING conda.core.envs_manager:register_env(46): Unable to register environment. Path not writable or missing.
environment location: /home/qualia/anaconda3
registry file: /home/qualia/.conda/environments.txt
done
installation finished.
Do you wish the installer to initialize Anaconda3
by running conda init? [yes|no]

Can somebody help by chance, I'm really lost.

formal schooner
#

@potent orchid thats odd. how did you install anaconda

main olive
#

How can I have supervisor run a python script

#

in my venv?

dull herald
#

is it possible to sed insert a string into a file ( without -i option) and awk the line position of that string? I'm trying to insert a string to a file, sort it, then awk the position. But I don't really want to append the string until the test is good

oak shell
#

not sure if I understand you correctly. Could you give a small input/output example?

dull herald
#

For example in a text file:

boreal kestrel
#

cat file | sed -r 's/search/replace/g' | grep -n replace | cut -d ':' -f 1 ?

dull herald
#

text.txt

Alpha
Omega

sed "$ a Beta" text.txt

Alpha
Omega
Beta

Sort

Alpha
Beta
Omega

awk command to grab the line num

2

#

I dont wanna search and replace

oak shell
#

So you basically want to sort a list of lines, insert a new item in the right place and get the new line number of that item?

dull herald
#

This works if i run the commands right after each other only if i actually write to the file

boreal kestrel
#

I see. So you want to:

  1. append data to file
  2. sort data after append
  3. fine where the new data should be added?
dull herald
#

yea but my question is if it is possible to figure out where that data's line number would be

#

if i dont write to it

boreal kestrel
#

cat <(cat <(echo "Alpha") <(echo "Omega")) <(echo "Beta") | sort | grep -nP "^Beta$" | cut -d ':' -f 1

dull herald
#

figure out the caluclation through output

boreal kestrel
#

replace <(cat <(echo "Alpha") <(echo "Omega")) with the name of your file

dull herald
#

imagine

#

the text file has 140 lines already

boreal kestrel
#

sort and grep are fast πŸ™‚

dull herald
#

so ur suggesting to do 140 cats

#

lol

boreal kestrel
#

???

#

no

#

cat file <(echo "Beta") | sort | grep -nP "^Beta$" | cut -d ':' -f 1

dull herald
#

that gave me every strings line number

boreal kestrel
#

Is your line unique?

oak shell
#

I'd use grep -Fnx 'Beta' instead, in the command above. Fixed string full line match.

boreal kestrel
#

Huh, learn something new everyday

dull herald
#

sed -i "$ a hello" text.txt; sort -no text.txt text.txt ; awk '/hello/{ print NR; exit}' text.txt

#

this is a working example

#

of what i want

#

but it does require me to write to the file first

oak shell
#

you could just remove the -i and write to a different file name with > text2.txt

boreal kestrel
#

Consider:

$ cat <(echo "foo"; echo "bar"; echo "lol"; echo "surely you meant to hello")
foo
bar
lol
surely you meant to hello

Then:

$ cat <(echo "foo"; echo "bar"; echo "lol"; echo "surely you meant to hello") <(echo "hello") | sort -n
bar
foo
hello
lol
surely you meant to hello

Then:

$ cat <(echo "foo"; echo "bar"; echo "lol"; echo "surely you meant to hello") <(echo "hello") | sort -n | grep -Fnx hello | cut -d ':' -f 1
3
dull herald
#

awesome! thats exactly what I wanted. get the line number without actually writing to the file

#

thanks for your help guys!

boreal kestrel
#

yw

main olive
#
[2019-08-22 19:33:34 +0000] [21054] [INFO] Worker exiting (pid: 21054)
[2019-08-22 19:33:34 +0000] [21062] [INFO] Booting worker with pid: 21062
[2019-08-22 19:33:39 +0000] [20750] [INFO] Handling signal: term
[2019-08-22 19:33:51 +0000] [21075] [INFO] Starting gunicorn 19.9.0
[2019-08-22 19:33:51 +0000] [21075] [INFO] Listening at: http://127.0.0.1:8000 (21075)
[2019-08-22 19:33:51 +0000] [21075] [INFO] Using worker: eventlet
[2019-08-22 19:33:51 +0000] [21078] [INFO] Booting worker with pid: 21078
[2019-08-22 19:34:21 +0000] [21075] [CRITICAL] WORKER TIMEOUT (pid:21078)
[2019-08-22 19:34:21 +0000] [21078] [ERROR] Socket error processing request.
Traceback (most recent call last):
  File "/home/dom/domalert/venv/lib/python3.6/site-packages/gunicorn/workers/base_async.py", line 66, in handle
    six.reraise(*sys.exc_info())
  File "/home/dom/domalert/venv/lib/python3.6/site-packages/gunicorn/six.py", line 625, in reraise
    raise value
  File "/home/dom/domalert/venv/lib/python3.6/site-packages/gunicorn/workers/base_async.py", line 39, in handle
    listener_name = listener.getsockname()
OSError: [Errno 9] Bad file descriptor
[2019-08-22 19:34:21 +0000] [21078] [INFO] Worker exiting (pid: 21078)
[2019-08-22 19:34:21 +0000] [21106] [INFO] Booting worker with pid: 21106
[2019-08-22 19:34:51 +0000] [21075] [CRITICAL] WORKER TIMEOUT (pid:21106)
[2019-08-22 19:34:51 +0000] [21106] [INFO] Worker exiting (pid: 21106)
[2019-08-22 19:34:51 +0000] [21120] [INFO] Booting worker with pid: 21120```
#

uhhh why do I get that error

#

using ubnutu 18.04 flask/nginx/gunicorn

boreal kestrel
#

The bad file descriptor means that you're doing something with a file or socket which has been closed

main olive
#

but thats so wierd cus i start up my app

#

and i get this instantly

boreal kestrel
#

Look at listener and verify that it is a valid listening socket.

main olive
#

whats listener?

boreal kestrel
#

I don't know. You tell me.

#

Look at the error and see.

main olive
#

lol thats from gunciorn not my file sad

boreal kestrel
#

(it's probably a socket or something that holds a socket, and it probably needs to be told to listen() before it will work)

main olive
#

its pointing the /home/dom/domalert/venv/lib/python3.6/site-packages/gunicorn/workers/base_async.py

#

as the file for the error

boreal kestrel
#

Have you read gunicorn's documentation and/or code around the error?

main olive
#

Tried but I didn't see anything that applied to my code

boreal kestrel
main olive
#

fixed it

#

uninstalled gunicorn and reinstalled it

boreal kestrel
#

πŸ‘

drifting vector
#

I have a webscraper using Selenium that runs once an hour on a macOS server with cron. At the end of the script, I have driver.quit() to kill the process, but somehow I always end up with a ton of Firefox processes that bog the server down. When I evoke the script directly it behaves like I expect, the Firefox process appears, does its thing, and then vanishes. But somehow when it's evoked via cron the process never goes away. As a bandaid, I have pkill -f Firefox going off at regular intervals. Can't seem to figure out how to have the script terminate it though - I suppose I could fetch the PID and use subprocess to kill it directly? Just seems like I'm missing something obvious, perhaps related to how cron behaves.

boreal kestrel
#

Are you sure you're reaching the point where you call driver.quit() when you're launched by cron?

#

If the Firefox processes are in the zombie state (Firefox exited but its kernel information hasn't been reaped), then it is likely that your script isn't waiting for the child Firefox process to finish before you exit. In that case, Firefox becomes owned by cron and then cron just chills because it only reads its own direct children processes. I'm not familiar with Selenium but if it asynchronously asks Firefox to exit and then returns execution to you while Firefox begins to clean up, then zombies could also be a symptom of that.

If the Firefox processes are still running/sleeping (not in a zombie state), then I'd venture a guess that your script is exiting without calling driver.quit().

drifting vector
#

yea, looks like the process was terminating early. Not sure why it was only happening with cron though, will investigate. thanks!

worn apex
#

@boreal kestrel zombie processes do not become owned by cron, processes go to init, not a grandparent process, when the original parent process dies

#

(and zombie processes shouldn't take up significant resources anyway)

boreal kestrel
#

Ahh I thought when a child process dies, the parent inherits any descendents of the child

worn apex
#

nah, precisely because the parent can't be relied on to handle random descendant processes exiting

#

whereas init is designed to handle them because that has always been one of its jobs

#

(the example in your stackexchange answer is the shell spawned directly by cron)

boreal kestrel
#

Is there a way to change it so that a parent would receive its grandchildren instead of init? I could imagine it being done in a container if the parent now has pid 1

boreal kestrel
#

"subreaper" new term to me. Thanks!

main olive
#

So I'm trying to send this text to /etc/nginx/sites-enabled/dommy like this ```

sudo touch /etc/hginx/sites-enabled/domalert
echo "server {
listen 80;
server_name ;

location /static {
    alias /home/dom/domalert/domALERTV5/static;
}

location / {
    proxy_pass http://localhost:8000;
    include /etc/nginx/proxy_params;
    proxy_redirect off;
}

location /socket.io {
    include proxy_params;
    proxy_http_version 1.1;
    proxy_buffering off;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'Upgrade';
    proxy_pass http://localhost:8000/socket.io;
}

}" >> /etc/nginx/sites-enabled/domalert``` but the text doesn't go into the file properly

main olive
#

okay, first off

#

you're touching in a dir named hginx

#

secondly, since you're using double quotes, you need to escape things like $http_upgrade since bash will try to expand it as a variable, which just.. deletes it

#

third, you're echoing this to domalert not dommy

#

just use vim or nano please

#

@main olive

#

alternatively, you can do the cat > [filename] << EOF trick if you absolutely do not want to use an editor, but I think you still have to escape dollar signs

#

i saw the hginx issue and fixed it

#

so how should i escape the $http_upgrade?

#

\$http_upgrade

#

that should prevent bash from trying to expand it

#

ok

#

also, I think the nginx convention is to put the real config to sites-available and symlink it to sites-enabled

#

also, don't forget to restart nginx

#

rlly? cus i've been putting it in sites-enabled and its been workin

#

ah yeah it probably works fine but it's just ugly

#

but it doesn't really matter

#

πŸ‘Œ

#

got it working?

main olive
#

trying it now

somber stirrup
#

I think best practice is putting it in the conf.d folder. sites-* is an apache thing that was adopted for convenience

vagrant fern
#

conf.d is simpler if you use something like ansible, sites-x when you do it manually

somber stirrup
#

I read it in a guide somewhere

vagrant fern
#

Iβ€˜m running LVM on LUKS with ext4 on my logical volumes. I have a separate LV for /home, and I only have a single vg with a single pv, which is a 2 TB HDD. For some reason, IO performance is very hard to instrument. for instance, downloads happen with 1-2 MB/s at most, but iotop shows that the disk is basically idle. CPUs are not busy either and no iowait is in sight. Iβ€˜m not sure how else to look whatβ€˜s bottlenecking - whats the best way to check this?

#

Also, Iβ€˜m currently looking at the following things:

  • add a nvme ssd, as a caching lv in writeback mode (simplest)
  • adda nvme ssd to the vg, drop the hdd from the vg
  • reinstall on ssd
    Iβ€˜ve done 1. previously, but is anyone else running a similar setup?
boreal kestrel
#

Downloading? What makes you think downloading is slow because of your hard disk? Are you sure it's not your internet? Or even the uploading server?

Unix and Linux in particular have a metric ton of caching involved. Some simple ways to avoid cache is to always use random data. Say for example time head -c $((1024 * 1024 * 1024)) /dev/urandom > /some/path/on/disk. If it's still 1-2MB/s then yeah start looking at... uhhh... more caching layers like the nvme stuff you mentioned. But if it's a lot faster then I don't think your disk is slow. For comparison, I have some 2TB HDDs with ext4+LUKS going over USB3.0 to an external case. I typically get about 110 or so MB/s which is fairly on par with performance I've seen with most spinning rust

vagrant fern
#

I was looking at the download tab in steam - networking speed always settled at ~100 kB/s, and disk speed seemed to max out at 2 MB/s

#

My network speed is around 10 - 12 MB/s, so I doubt that's the issue. head on /dev/urandom bottlenecks on the CPU as far as I can tell. Wouldn't /dev/zero be more appropriate?

#

uh-huh, /dev/zero suggests it would write 1 gigabyte in half a second. that seems a bit wrong πŸ€”

oak shell
#

keep in mind writing/accessing many tiny files is significantly slower than one large of the same total size

main olive
#

very true

#

lots of overhead from inode lookups, acquiring locks and the like

sage solar
#

the writing 1 Gigabyte of zeroes in half a second thing could be because your hard disk supports just erasing a sector with one instruction I guess? Because just that one instruction vs a write with certain data is definitely gonna be faster

#

but that's just guessing at this point really

#

Β―_(ツ)_/Β―

woeful drum
#

Is there a tool to copy terms to translations (gettext) from bash?

main olive
#

what are you trying to achieve?

torn snow
#

@vagrant fern remember there's a lot that can bottleneck in a network, e.g. depending on the location of the Steam network, your network bandwidth, etc

#

In general, if you're really exhausting your disk I/O, your entire system would probably lag like heck

vagrant fern
#

yeah thats true

tame crystal
#

Hey guys, my teacher said we should start getting comfortable with linux

#

I know at school we will eventually use redhat

#

right now I only have windows 10

#

I need some linux distro

#

which one should I get? I am thinking either ubuntu b/c it is easy to learn and most unix server us it or fedora because it is like redhat

#

any advice?

hollow skiff
#

I'm also interested in getting Unix, I've used Windows all my life but I'd like to try out Ubuntu or whatever else someone might recommend

formal schooner
#

I would guess ubuntu probably has the best hardware support

#

Xubuntu is probably a good option

tame crystal
#

is that xfce?

#

how easy is it to go in between ubuntu and redhat?

formal schooner
#

I dont know ubuntu well but i know debian

#

Its not that different, you have to learn the package manager mostly

#

And the way they configure things in /var /etc and the like are a bit different

#

I dont know SELinux really, ubuntu/debian i think more often use apparmor

#

If you know "linux" well then you should be fine

#

I used to use centos at work, it didnt break my brain switching to debian

tame crystal
#

centos is like redhat/fedora isn't it?

formal schooner
#

Centos is a free public LTS

#

The opposite of fedora which is rolling

main olive
#

@tame crystal @hollow skiff I recommend Kubuntu for a newcomer

#

it's ubuntu, but KDE Plasma as the default interface + KDE applications

#

and it's great

tame crystal
#

better than fedora?

main olive
#

I mean, there is no "better" distro

#

they're meant for slightly different purposes

vast ocean
#

im trying to get full path to a shared library, is that possible?

#

i only get lib name with find_library()

#

and there is no attribute on cdll that contains the path

formal schooner
#

@main olive isnt KDE somewhat of a learning curve though?

main olive
#

definitely not

formal schooner
#

Versus XFCE or LXDE

#

Or Mate or Cinnamon

main olive
#

well my 70-something grandmother picked up Plasma pretty instantly

#

if there is a learning curve, it's not very steep

formal schooner
#

That's good to know

hollow skiff
#

Okay ill try out Kubuntu then. Thanks

main olive
#

how do i setup ddos protection on my vps

#

so it can survive ddos attacks

bold cave
#
Status:    Connecting to 157.245.47.106:21...
Status:    Connection attempt failed with "ECONNREFUSED - Connection refused by server".
Error:    Could not connect to server```
#

trying to connect with file zilla

#

I am sure the password is correct

#
Status:    Connecting to 157.245.47.106...
Response:    fzSftp started, protocol_version=8
Command:    open "root@157.245.47.106" 22
Command:    Trust new Hostkey: Once
Command:    Pass: ********
Error:    Authentication failed.
Error:    Critical error: Could not connect to server
#

doesnt work when I try and connect like this as wekk

#

shouldI be trying to connect to this isntread?

#

instead

#

@formal schooner do you have any ideas man?

formal schooner
#

no sorry

bold cave
#

@formal schooner do you think its cos im trying to connect without a port

#

could that be it

#

or anh

#

yeh it was

#

horray

#

fixxed

gritty bobcat
#

How can I install a windows-like gui to a google cloud compute server? :D

torn snow
#

@main olive you probably want a service like CloudFlare

#

@gritty bobcat err Windows-like? Cloud compute server? It's kinda doable but probably not the best idea...

gritty bobcat
#

What would be the real reasons that would make it a bad idea? :D

formal schooner
#

install an X server on your computer, install XFCE on the server

torn snow
#

You generally don't want to install an entire graphical environment on a headless server, it's pointless bloat that eats resources and adds another potential attack vector, also it's usually not necessary...

formal schooner
#

that too

torn snow
#

If you just want a UI to use for admin tasks check out Cockpit

main olive
#

@gritty bobcat you install a graphical interface and set up X forwarding

main olive
#

@torn snow well im setting up a vpn and ya

torn snow
#

Yeah if it's for admin config definitely check out Cockpit, it's built for this type of stuff

main olive
#

wdym @torn snow

torn snow
#

Like for admin tasks

#

Cockpit is a web UI that's designed for managing servers

main olive
#

i think you're responding to the wrong dude @torn snow

torn snow
#

Dammit

#

🀦

#

You'd think I'd learn at this point that late night discord generally ends badly

main olive
#

:D happens to the best of us

plain adder
#

I have a python command line tool, that I converted to a unix executable using pyinstaller. where do I need to put the exe or change a option in the system settings so it can directly be run from the terminal with $ <program name> without using the path $ /path/to/unix/executable?

robust cave
#

the directory your program is in must be on PATH, which can be seen by running echo $PATH. I'd put it in /usr/bin to respect the Linux Filesystem Hierarchy Standard

plain adder
#

?

#

Could you repeat that a bit more clearly, didn't really understand it.

robust cave
#

PATH is a special environment variable to tell the shell which directories to search in, and in what order, for executable files

#

if you run echo $PATH, you can see a list of directories separated by colons, :

#

technically moving the executable to any directory found in $PATH will do, but for best practices, either place it in /usr/bin or add your custom directory to your $PATH

plain adder
#

ok

#

What is the best way to move a copy of the program to that directory?

#

And remove if it afterwards if the user doesn't want it there anymore?

main olive
#

I would use /usr/local/bin

#

that's what the local dir is meant for, specifically

#

the safest option would be to just copy the binary there as root, sudo cp /path/to/executable /usr/local/bin

#

if you don't want to re-copy it every time you make a modification to it, you can create a symbolic link to it, so

#

sudo ln -s /path/to/executable /usr/local/bin/executable

#

however keep in mind this has security implications, as you don't need to be root to change the contents of the executable

#

this means that, for example, if you run the executable usually as root, another application running as your user can insert something evil into it, which then gets run as root next time you execute it

#

this isn't the only attack vector but probably the most obvious one, so I'd just stick to copying it in there

#

and anything which can modify files like that can also modify your $PATH environment variable to point to somewhere evil instead, so it's kind of moot anyways

#

however, am I right in assuming you're developing a program and want other users to be able to run it with just $ executable? @plain adder

#

in this case, you should realistically be building packages instead, so the user's package manager can handle the installation and uninstallation of your program

#

.deb for debian systems, PKGBUILD alongside source for arch packages, etc

plain adder
#

Thats a whole lot of info.

#

The program does nothing more than taking some weather data and another 20 integers as inputs, pulls it through some complex formulas and outputs a .csv.

#

I was planning to have a option in the executable that would copy it to /usr/local/bin and another option to remove it again. It doesn't need to be linked.

#

How could I open a unix executable as a plain text file or something? to view its contents

#

Adding .txt just makes a big mess of symbols.

#

Could you give me a detailed instruction of how to package my program or tell me where I could find info on it.

main olive
#

How could I open a unix executable as a plain text file

#

you don't. :) it's compiled to native machine code

#

it's why "reverse engineering" exists.. you take the machine instructions and "reverse engineer" the logic

#

you can never get the original source code of a compiled binary

#

tell me where I could find info on it

#

Google. "building package for [distro]"

plain adder
#

ok

main olive
#

I did a sin, lord forgive me
I installed RHEL on laptop with bumblebee, flatpak that is driving some apps and collection of 3rd party repos

#

RHEL 7.7 more precisely

plain adder
#

@main olive I think that making a package for this program isnt worth it, it is too simple. Is copying the binary as root to /usr/local/bin safe?

#

And is it possible to execute sudo cp /path/to/executable /usr/local/bin from a python program?

main olive
#

Yes, it's entirely possible

#

And safe enough as long as you make sure not to overwrite anything

#

So, check if a file named like that already exists

plain adder
#

ok

#

So no evil could be injected?

#

Is it ok if I ping you? @ xx

#

I will post some snippets from my code once i finish to see if it is safe.

torn snow
#

I installed RHEL on laptop
I've seen worse but...

#

7.7
y no 8

main olive
#

@dudaskule#0857 sure dude ping away

#

what

#

@plain adder

#

discord keeps doing that

main olive
#

@torn snow I'll tell you right now, NVIDIA is one hell of a bitch on RHEL 8 and it kept locking down for some odd reason, I am waiting for proper EPEL 8

#

8.1 is still in Beta and I am expecting some fixes and serious improvements

#

Especially Linux 5.1 DRM backported

#

I don't game so I didn't have need for Fedora and didn't need something that didn't update as Arch Linux since my internet is shit (currently 4 / 0.5, waiting for 200/100 optics infrastracture update)

torn snow
#

Oof lockups suck

#

But for nvidia, does rpmfusion not ship them for RHEL?

#

oof yeah they don't for 8 yet

plain adder
#

@main olive So if i use sudo cp /path/to/executable /usr/local/bin no evil can be injected

boreal kestrel
#

alias cp=dosomethingelseinstead

main olive
#

a random question about shell but is anyone here familiar with ctrl+r / s history lookup sequence?

#

everytime i bring up a past command (first to ctrl+r mutliple times, -> stop at the command i want -> ctrl + e or j ), some portion of the selected command is cut off in the shell

#

only ctrl+l (clear) makes the whole command appear again and it's frustrating

#

anyone with any idea?

torn snow
#

I've seen history issues kinda like that in bash but not sure about the cause

main olive
#

@torn snow RPMFusion is shipping for RHEL 8 but drivers don't want to run Xorg, its really pissing me off, I have RHEL workstation with NVIDIA Quadro for coding but I needed laptop when I am abroad with school

main olive
#

@plain adder "no evil can be injected"

Evil can always be injected. For example, something can just edit the script. The chances for that are pretty low, though. PATH poisoning might be more likely. How this works is that some malicious application changes the user's PATH env var, and points it to a directory with malicious versions of binaries such as cp, that will be executed instead of the legitimate cp on the system.

This can be avoided by using absolute paths for called binaries, so something like /usr/bin/sudo /bin/cp whatever whereever

#

this way, you're not relying on PATH at all

plain adder
#

i meant, no evil could easily be injected

main olive
#

@boreal kestrel that actually won't work with default configs

#

sudo ignores aliases

plain adder
#

so i would just directly point the path to the executable.

main olive
#

yes, so /usr/bin/sudo instead of just sudo, same for cp

#

please keep in mind that these binaries are not in the same location for every distro

#

which is kinda fucky

#

but they're almost always either in /bin or /usr/bin

#

so just check both, imho

#

this is something to keep in mind for all external commands called from a script, btw

plain adder
#

Is there possibly any way to call the executable as a command without moving it to /usr/bin/sudo

main olive
#

???

#

Don't move ANYTHING to /usr/bin/sudo, please...

#

that would overwrite the sudo binary, which is not good

plain adder
#

ok

winter obsidian
#

Hey there
I got a question about booting knoppix live
I downloaded the ISO file (knoppix ver: 8.6) and burn it to my disk
My problem is, when i head to boot options and configure an option, like language or desktop env, i stuck on the following screen

#

It just stuck here, nothing happens
This happens only when i head to boot options and change something, it doesnt matter what i change

boreal kestrel
#

@main olive alias sudo="echo hello world"

main olive
#

@boreal kestrel also probably wouldn't work as alias is scoped to the current shell only

#

well, it depends I guess

somber stirrup
#

I've got this pacman hook

[Trigger]
Type = Package
Operation = Install
Operation = Upgrade
Target = xmonad
  
[Action]
Description = Recompiling Xmonad
Exec = "/usr/bin/xmonad --recompile"
When = PostTransaction
Depends = xmonad

But when it runs I get

(6/6) Recompiling Xmonad
call to execv failed (No such file or directory)
error: command failed to execute correctly

But it's definitely there

[11:30] zer0 $ which xmonad
/usr/bin/xmonad
warped nimbus
#

Is it on path for root too?

#

presumably pacman runs as root

somber stirrup
#

Okay the "not found" issue was because of the quotes.

#

Removing them made it able to find it, now it's running as root which is a problem

#

Fixed!

Exec = /usr/bin/runuser -l zer0 -c 'xmonad --recompile'
main olive
#

"freeze python code"

#

?????

#

elaborate

fossil parrot
#

Anything I should pay special attention to when trying to install Linux to a Windows laptop for dual boot?

raw tapir
#

the only problem I have had my self so far is that the clock get's reset since they use different time systems. but it's a ez fix. let me see if I can find it again for you.

fossil parrot
#

Thanks!

#

im just setting up Manjaro atm for dual boot

raw tapir
#

only thing I have noticed, idk if there is more.

fossil parrot
#

Really hoping it doesnt mess with Windows10 EFI bootloader, cause i heard dual boot can be a pain

raw tapir
#

it went smooth for me when installing ubuntu from a usb to a windows 10 dual boot.

fossil parrot
#

alright here goes nothing then

fossil parrot
#

@raw tapir seem to be stuck in Grub loader :/

blissful sage
#

not sure if this is the right place

#

I belive my IDE is not pointing to the right location

#

it only seems to work when I follow this method

#

specifically

#

the last section by user "Lawrence Coleman"

#

for some background, I installed homebrew and kind of messed up my computer, but then got it to work again by reinstalling and using pyenv to manage my python versions

#

and then pipenv to manage my environments (I know it's a bit redundant as they have some funcitonal overlap)

outer reef
#

Alright, remind me. If I'm lazy and don't want to type out the whole folder name to cd into it, isn't there a like short hand way to get into it?

#

Ah HA

#

Tab

main olive
#

@outer reef if you use zsh, you can install some plugins which basically give steroids to the tab auto-completion

#

it can contextually complete paths, program arguments, program flags, network paths, so on and so on

outer reef
#

This was just a small thing for WSL, not enough of an issue to warrant it

main olive
#

ah alright

#

thought you were getting into linux for a second there feels

outer reef
#

I have Manjaro on my laptop at home

dull niche
#

why is linux better

main olive
#

Depends on your usecase

somber stirrup
#

Linux is powerful because it gives the user a lot of control

heavy frost
#

so im trying to screen a bot

#

ive installed everything

#

but running screen -AmdS <name> python3.7 <file>.py doesnt work

#

if i make a new screen manually and run it that way

#

its fine

#

but im assuming its import errors

#

but if i try and reinstall the imports

#

it says already satisfied

#

any help?

heavy frost
#

ok found the issue

#

python 3.7 doesnt have a folder for some reason

#

but py 3.6 does

somber stirrup
#

I've got a long running process on a remote server. Right now I'm launching it manually then detaching. What's best practice for checking on that process? Would I just save the pid?

#

The virtual env is getting in the way of pgrep I think

#

I could always just grep it

#

Yeah that seems fine

main olive
#

or set up a systemd unit/service

#

that usually works great as well

somber stirrup
#

Eventually!

blazing wolf
#

hey guys

#

I have been using windows through out my life now and i have been hearing a lot about linux now

#

what is the reason people use linux for?

vestal turret
#

You have spoken to wise men.

blazing wolf
#

like developers n stuff

#

im very new to linux, help me

vestal turret
#

What questions do you have.

blazing wolf
#

reason to use linux?

#

and what is this ubuntu

vestal turret
#

ubuntu is a linux distribution.

blazing wolf
#

and what would someone use a linux terminal on a windows machine?

#

lot of questions

vestal turret
#

Ask for reasons to use, it's fast on older hardware, a lot of devtools are avaiable and fit in well with the environment.

blazing wolf
#

ohk

vestal turret
#

You can use windows subsystem for linux to use a linux terminal on windows.

blazing wolf
#

oh

vestal turret
#

There are a few of those avaiable in the windows store.

blazing wolf
#

what perks i get with that

#

what can i do with linux terminal

#

like whats the reason people download it

vestal turret
#

It's mainly for running linux software iirc. I've never used it on windows myself.

blazing wolf
#

oh okay

#

git bash is linux terminal right?

vestal turret
#

That's just for git I think.

#

For a full one, look up one in the windows store.

blazing wolf
#

okay

warped nimbus
#

Git bash will work everywhere and for anything, it's not just for git

main olive
#

yeah, git bash is just an msys2 instance with git installed

edgy minnow
#

its using cygwin is it not... (or is that just the optional bash shell git provides iirc)

somber stirrup
#

@blazing wolf Linux is basically an IDE

#

In the context of development

#

It gets out of your way and gives you unrestricted control over your computer

#

It's a matter of preference mostly. If you're willing to learn the command line then I'd highly recommend it

blazing wolf
#

Okay

nimble quarry
#

@echo tinsel install the python3.6-distutils package (or something like that)

#

Checkout pip's documentation about its installation then πŸ€”

main olive
#

@echo tinsel this is sort of what virtual environments are for

robust cave
#

@echo tinsel should be python3-distutils instead IIRC, try that?

main olive
#

that installs it into 3.7 iirc

#

you could, maybe, extract the .deb and place the files into the 3.6 installation manually, but that's a bit.. eh

robust cave
main olive
#

environments really are the way to go

robust cave
#

how would you create a virtual environment using Python 3.6 if you don't have Python 3.6 though? Can it be done?

main olive
#

I know Anaconda can do it, I've used it loads with machine learning projects which require a specific python version

#

not sure about pyenv

#

yeah

#

pyenv install 3.6

#

downloads and bootstraps the python version

#

and pip, looks like

vagrant fern
#

why wouldnβ€˜t you use 3.7 though?

rich lynx
#

Hello, i started computer science school today they require me to work on linux. Can I install ubuntu or linux mint to have the same command prompts ? (And will everything will work the same ?)

formal schooner
#

@rich lynx the same compared to what?

ebon jasper
#

Compared to a Linux computer I think @formal schooner

sharp shell
#

would have to wait for clarification from the original commenter to make sure

rich lynx
#

For example if I use a command in ubuntu

#

Is the command the same on linux mint ?

#

(Sorry for being unclear)

robust cave
#

essentially, yes. Linux Mint specifically is a derivative of Ubuntu, so they are pretty similar for the most part

main olive
#

mostly what you have to watch out for is stuff like installing packages (different distros have different package managers), everything else is usually (not always) the same

#

mint and ubuntu use the same package manager, dpkg

rich lynx
#

Ok thanks

#

A lot

somber stirrup
#

@echo tinsel pyenv is an amazing tool for managing your python versions

#
# install pyenv (make sure you have curl) 
curl https://pyenv.run | bash
# may have to open a new terminal
pyenv install 3.6.7
# make "python" in path point to 3.6.7
pyenv global 3.6.7
# make "pip" and other python tools use 3.6.7
pyenv rehash
limber gyro
#

Guys who's using manjaro xfce?

gritty bobcat
#
<name> $ sudo dpkg --configure -a
Setting up mariadb-server-10.1 (10.1.38-0+deb9u1) ...
dpkg: error processing package mariadb-server-10.1 (--configure):
 subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of default-mysql-server:
 default-mysql-server depends on mariadb-server-10.1; however:
  Package mariadb-server-10.1 is not configured yet.

dpkg: error processing package default-mysql-server (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of mysql-server:
 mysql-server depends on default-mysql-server; however:
  Package default-mysql-server is not configured yet.

dpkg: error processing package mysql-server (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 mariadb-server-10.1
 default-mysql-server
 mysql-server
#

Any ideas?

gritty bobcat
#

):

boreal kestrel
#

@gritty bobcat I am sure there is a MariaDB and/or MySQL support area. I imagine they'll be better able to help you debug your installation.

gritty bobcat
#

Ok, I'll give that a go

main olive
#

hmm

#

@gritty bobcat Have you tried
sudo apt --fix-broken install

#

Also use their repositories

gritty bobcat
#

Thanks, I fixed the issue, ty for the help blobsmilehappy

main olive
#

np, I would love to help anybody in trouble*

blazing wolf
#

im having some issues with pip in linux

#

from the pycharm terminal

#

pip install pipenv Traceback (most recent call last): File "/usr/bin/pip", line 9, in <module> from pip import main ImportError: cannot import name main

#

im new to linux

warped nimbus
#

First, are you sure /usr/bin/pip is for python 3?

blazing wolf
#

there are 3 python installed, lol

warped nimbus
#

That doesn't mean much

blazing wolf
#

how to check that

warped nimbus
#

Lots of distros come with python 2

main olive
#

which pip

warped nimbus
#

Or pip --version

blazing wolf
#

mine came with 2.7 and 3.6 and then i installed 3.7

warped nimbus
#

which pip is /usr/bin/pip

#

already shown in the log

main olive
#

ls -l $(which pip) 😏

#

the fuck dude

warped nimbus
#

You probably want top be using python3 -m pip install ...

blazing wolf
#

okay

#

okay i got the prob

#

pip is not of 3.7

#

i did sudo apt install python-pip

#

before

main olive
#

python3-pip, maybe

blazing wolf
#

okay

warped nimbus
#

Still, you'd likely need to use pip3 or what I showed above

blazing wolf
#

okay

#

how do i remove the python-pip which i had installed already?

main olive
#

you probably don't want to remove it

blazing wolf
#

okay

main olive
#

update-alternatives can change what the default pip points to

blazing wolf
#

okay

#

can u guys also tell me how to make a new pipenv with existing pipfile

warped nimbus
#

just run pipenv install and it will detect the pipfile

#

if you want to delete the old venv just delete the folder

#

I think there may be a pipenv command to delete it too

blazing wolf
#

okay

#

i dont have any envs yet

#

moved to linux today

#

now it says pipenv command not found

#

should i do like python3.7 -m pipenv install?

warped nimbus
#

Maybe

blazing wolf
#

okay its working

#

πŸ™‚

warped nimbus
#

I glossed over the fact you also have 3.6

blazing wolf
#

and 3.7

#

3.6 came with the distro

#

2.7 too came with the distro

#

how do i select it as project interpretor

#

existing virtualenv?

warped nimbus
#

yes

blazing wolf
#

Hey guys

#

I'm facing some prob with Ubuntu mate

#

It's been freezing

#

Happened twice today with a time interval of around 1 hour

#

Anyone knows what's causing it

#

And solutions

blazing wolf
#

nvm

stone ingot
#

@blazing wolf for the second question I don't know it's too ambiguous, for the first one, do you use both pythob versions? anyway the python version you used to install the veturtualenv tool is the one will be used

ornate ledge
#

@blazing wolf python3 -m venv <myenvname>

#

will create a py3 virtualenvironment

#

so when you activate it

#

interpreter will be set to py3

blazing wolf
#

I solved the first one πŸ˜…

#

Thanks anyway

rigid vine
#

If my system (Arch) offers packages also available through pip, which should i prefer? For example, pipenv

warped nimbus
#

I would say the arch packages

#

Actually

#

If you install with --user that's OK too

#

If you want to get updates ASAP using pip may be better

#

But using the arch packages is nice cause you can update a bigger portion of your system with a single command

#

Instead of having to worry about updating pip dependencies separately

rigid vine
#

Yeah, I've been a bit conflicted on this for a bit, i'll go with system packages, since pip isn't as nice to use for mass-updates

warped nimbus
#

I wonder if --user could conflict with packages installed globally

#

I know doing it manually results in the package just being moved from user site to global site

rigid vine
warped nimbus
#

And in the context of arch, that could happen because other packages could depend on a python package

rigid vine
#

actually this seems to be for installing system packages through pip install while already having installed them with --user, not arch python-X packages

warped nimbus
#

Don't arch packages go through pip anyway?

#

IDK if that's the same thing as pip

rigid vine
#

i think setup.py build adds to pip? i haven't looked into it all that much

warped nimbus
#

But you get my concern right?

#

with --user

rigid vine
#

i think, yeah. but honestly, i haven't been good about using envs and have just been installing globally

warped nimbus
#

⚠

rigid vine
#

yeah, yeah πŸ™„ i've been meaning to for a while, pipenv just confused me before and i gave up on it i think twice, but i finally got it
i do recommend others use venvs, though

warped nimbus
#

To be honest I think the way Python works with linux is a bit of a mess

#

You're essentially dealing with 2 different package managers

#

The worst part is that packages on arch get outdated

#

and you have to rely on maintainers to update the pkgbuild

#

It's kinda dumb

#

For example python-virtualenv has been outdated since April

#

And that's a popular package

rigid vine
#

good thing i don't use virtualenvs πŸ‘€

marble bluff
#

other than the results of ldd, what does python need

#

i found a script that conveniently and really nicely copies over all dependencies from ldd, but now i'm getting ModuleNotFoundError: No module named 'encodings'

#

oop

#

how would i go about programmatically copying all module files then?

#

...

#

nvm

#

sudo cp -r /usr/lib/python3.7/ /chroot/usr/lib/python3.7/

#

works

torn snow
#

@rigid vine poetry and pipx make using venvs pretty painless, personally I'm not a pipenv fan since it just felt awkward to use to me

#

@marble bluff so assuming you're on Linux I highly doubt that's going to work as well as you hope

#

What exactly are you trying to do?

#

If you're trying to portably distribute something, this is going to be a complete mess due to the way shared libraries are on Linux and how glibc handles forward compatibility

rigid vine
#

@torn snow thanks for the suggestions, though i think i'll stick with pipenv.
pipx doesn't fit the current case, and poetry's config just looks too strange to me (and it seems to be more for packaging to post to pypi)

torn snow
#

Rip

#

One nicety about poetry FWIW is that you rarely ever have to edit the file, you can poetry add dep and it'll automatically resolve the versions to use

somber stirrup
#

Pyenv is almost a must imo

#

Poetry and pipenv do have some overlap, but they are for different things.

warped nimbus
#

I like pyenv but don't feel it is a must

#

In unix python installations can live in peace side by side

#

You just may find it annoying having to be a little more specific in your commands

#

e.g. python3.7 or python3.6 instead of just python3

ornate ledge
#

personally, creating your own virtualenvironments in a directory, and installing and pip freezing is pretty satisfying and convenient. so, I agree with @warped nimbus on this one.

somber stirrup
#

To each their own πŸ™‚ I never go without it. Dependable as all hell, and all the versions of all the implementations are one command away

#

Well, two if you count the install script.

#

I still create virtual environments for my projects. Pyenv just lets me specify what version to use depending on the directory, which is so nice.

marble bluff
#

yap linux

#

uh no

#

i was just stuck on creating a chroot

warped nimbus
#

My point was just that describing pyenv is a "must" is a strong statement to make

#

I know it's your opinion and all

#

Maybe I was looking at it too objectively

#

Cause objectively you can accomplish the same thing without it and it wouldn't be that much more complicated to do

ornate ledge
#

@somber stirrup basically, let's just agree to disagree. functionality is same, if it's a must for you, it's a must for you πŸ™‚

somber stirrup
#

I was never disagreeing with you. Just expressing my opinion.

@warped nimbus I agree objectively it's unnecessary. Subjectively it's one of my favorite tools :)

ornate ledge
#

I didn't mean it in that sense, but okay cool πŸ‘

oblique mountain
#

I have a python script that downloads some stuff but I feel it's very slow is there a way to check the download speed while it's running ?

boreal kestrel
#

when you receive data, count the length of the data. then divide that over the amount of time passed since starting your download. that'll be the average byte rate per that unit of time.

somber stirrup
#

You could also use something like nethogs to monitor your network IO

granite sentinel
#

Hey, is there anyway to get the AST that bash builds for each command ?

main olive
#

you mean for builtins like pipes, boolean logic, redirections, etc?

#

I imagine you have to go hacking the source tbh

uneven silo
#

i did find a python module for that actually

#

its not great, but it does work

granite sentinel
#

Yes @main olive
Tell me more @uneven silo !

uneven silo
#

ill have to find it agaih

main olive
#

@uneven silo interesting, did you reimplement the bash operator logic in python?

uneven silo
#

i started making a discord bot with that purpose, and it worked fairly well

#

but some stuff happened and i put it away and haven't gone back yet

warm adder
#

sup guys, is there anyone using PyCharm under Manjaro/Arch? I'm getting a weird error importing pyperclip. Python console says 'successfully installed', but when I run the code, it says 'no module named 'pyperclip''

main olive
#

whats the proper way of adding a new user via a bash script on Ubuntu?

main olive
#

@main olive noninteractively?

#

the useradd utility

#

setting the password might require a bit of a hassle, if that's required

#

ended up doing this

#
sudo adduser myuser --gecos "First Last,RoomNumber,WorkPhone,HomePhone" --disabled-password
echo "myuser:mypassword" | sudo chpasswd```
#

but when I do sudo -u myuser mkdir dummydir I get permission denied 😦

boreal kestrel
#

There are several different implementations of adduser. Which one are you invoking? What is the output of adduser --help ? Why do you manually specicy --gecos?

#

Oh derp I guess it would help if I read more context. Ubuntu, so debian-based.

#

sudo -u myuser mkdir dummydir gives you permission failed because sudo runs mkdir in your current working directory in which myuser does not have permission to do anything

#

if you do sudo -u myuser bash -c 'cd ${HOME}; mkdir dummydir' you should see a difference

#

However, as far as "proper way of adding a new user via a bash script", I generally do something like this:

# true: wrapper to make everything copy-pasteable and have && prefixed to a new command. you can remove this if you're picky.
#
# adduser:
# -s: login shell. /usr/bin/false will prevent the user from achieving a shell if they log in. remove if the user should access a shell; you can still get to the user via `sudo` or `su`
# -d: specify a HOME directory. you might receive a warning if it already exists.
# -p: specify encrypted password. '!' will prevent typical login. you can still get to the user via `sudo` or `su`
# -l: don't add user to lastlog and faillog (important in a Dockerfile since Docker and sparse files (such as lastlog and faillog) don't play nice with each other)
#
# mkdir isn't usually necessary. I like being thorough.
# -p: don't fail if the directory already exists
#
# chown isn't usually necessary.
# -R: recursively.
true \
&& useradd \
  -s /usr/bin/false \
  -d /home/user \
  -p '!' \
  -l \
  user \
&& mkdir -p \
  /home/user \
&& chown -R user:user \
  /home/user \
&& true 

straight from a Dockerfile

main olive
#

is there someway i can just run a while seris of commands

#

as that user?

boreal kestrel
#

What do you think this does? sudo -u myuser bash -c 'cd ${HOME}; mkdir dummydir'

main olive
#

No I mean like

#

well nvm

boreal kestrel
#

Figured it out?

main olive
#

I realized there was prob no clean way to do what I meant

boreal kestrel
#

What do you mean?

main olive
#

use useradd instead of adduser

#

${HOME}; what does that do?

#

useradd is in coreutils and guaranteed to be more or less standard

#

that's just the home env var

#

Oh ok

boreal kestrel
#

funny enough useradd is provided by BusyBox in alpine and it's about as feature-different as can be expected for any BusyBox implementation

main olive
#

yeah, but, busybox

boreal kestrel
#

actually, useradd isn't even in alpine

#

it's adduser lol

main olive
#

are you sure?

#

is there an usermod?

warped nimbus
#

Yeah it is adduser in busybox

main olive
#

huh, til

boreal kestrel
#

yeah docker run --rm -ti alpine useradd --help -> executable file not found in $PATH

warped nimbus
uneven silo
#

@granite sentinel Found it finally. It's called bashlex

granite sentinel
#

Thanks man! This should be really useful

#

Especially since the ast can be dumped in a very readable format

uneven silo
#

the ast it makes isn't great, but with a little work, its manageable

main olive
#

clean kode

uneven silo
#

man.. im remembering what a meme this was

#

it was just a discord bot that took commands in bash syntax with some really gimmicky features

granite sentinel
#

Give Vaughn Pratt TDOP parsing algorithm a look, it might interest you. Parsed bash that way a couple month ago and it was a breeze

green sigil
#

Hi can I ask questions here about a virtual box set up ?

boreal kestrel
#

You can. Is it somewhat related to Unix? VirtualBox can run on and provide guests to many operating systems

green sigil
#

It is i am running vagrant using virtual box set up

#

I wanted to know how alias programs I use

#

I know how to alias but don’t know how within a vagrant/ virtual box set up

main olive
#

what's curl post get and delete

#

put too

sage solar
#

That's the http request types curl supports

main olive
#

I'm reading through this documentation for this backend I need to access data from, it says it supports those curl commands..

#

so should I just go with these.. how would I go about implementing in a python program.. use commands module?

#

subprocess?

sage solar
#

I mean in python you could just use the requests library instead of curl

main olive
#

oh cool

#

is that my best option?

sage solar
#

Requests is the http Lib which you'll find has the best user interface in python yes

main olive
#

requests all the way

uneven silo
#

unless you're doing async stuff

boreal kestrel
#

@green sigil Vagrant has an ssh command which lets you connect inside of your box. You should be able to eg alias mycommand=vagrant ssh box mycommand or something similar. You'll need to read the documentation for Vagrant about the specifics though: I've never personally used Vagrant so I don't know what more might be needed (such as authentication...?)

main olive
#

@boreal kestrel I tried using what you suggested yesterday sudo -u myuser bash -c 'cd ${HOME}; mkdir dummydir'

#

it didn't work and I still got permission denied

boreal kestrel
#

Interesting. What's myuser's home directory? Does it have correct ownership and permissions?

main olive
#

I added the user to the sudo group

#

using the script so I would think it has the correct perms

#
User1: File1.txt, File2.txt
User2: File3.txt

And I have a separate directory /fileNum that contains File4.txt and File5.txt
  How do I modify it so that ONLY User1 and User2 can modify File1.txt
And how do I make it so that the both users can edit the files in /fileNum, but not remove them?
I am just doing some basics of permissions in Linux (I am using Debian)```
boreal kestrel
#

@main olive I think there's something weird about your setup then. sudo adduser testuser && sudo -u testuser bash -c 'cd ${HOME}; mkdir testdir' worked fine on my Raspberry Pi with Raspbian (debian-based) and also worked fine in my Fedora VM.

main olive
#
sudo adduser myuser
sudo -u myuser mkdir /home/myuser/dom
``` ended up working for me
boreal kestrel
#

/hom ?

main olive
#

/home*

#

typo

boreal kestrel
#

πŸ˜›

#

Glad you got it working then

main olive
#

lol

#

thx

#

is there a way where I don't have to type the sudo password when running sudo commands for the first time?

boreal kestrel
#

sudo visudo /etc/sudoers -> man sudoers

#

look for NOPASSWD and make sure to read and think about any security impact

main olive
#

πŸ‘Œ

#

Wait isn't the command just sudo visudo?

#

to edit the file?

boreal kestrel
#

uh maybe it is

main olive
#

yea it is

#

no biggie

boreal kestrel
#

honestly I don't edit sudoers often

main olive
#

to edit the sudoers via a bash script its like echo "myuser ALL=(ALL) NOPASSWD:ALL" >> sudo visudo

boreal kestrel
#

lol no

#

try it, it will be harmless. you'll create a file named sudo in your current directory πŸ™‚

main olive
#

lol

#

i did

#

and it did that

#

πŸ˜‚

boreal kestrel
#

πŸ˜›

#

>> in bash will append the pipeline's stdout to the file, creating the file if necessary

main olive
#

oh

#

so it didn't realize i was trying to edit visudo and though i was trying to edit sudo?

#

like a file named sudo?

boreal kestrel
#

What do you mean?

main olive
#

like it thought i was trying to append the text to a file named sudo?

boreal kestrel
#

Yes

#

Take a look at the Pipe Operator

slow coral
#

yo so in .profile i have "setxkbmap -option caps:swapescape" and it works if i manually source it, but it doesn't swap them when I login. However, I also had to add python's bin to PATH in that file, and that line is working? any ideas?

boreal kestrel
#

Then also compare to the Redirection Operators

slow coral
#

ubuntu 19.04, zsh, idk what else you'd want to know?

boreal kestrel
#

@main olive when you run something like echo foo > bar, the shell will interpret > as a special instruction, a redirection operator. It's important to know that the redirection occurs before the program starts. So if you run something like sudo echo foo > /etc/foo, then the shell will try to create a file named /etc/foo as your current user. If your current user doesn't have permission then you will get permission denied. So instead you have to do something like echo foo | sudo tee -a /etc/foo if you want to write to a protected path. Make sure to man tee if you're unfamiliar with what it does.

#

It's also super easy to end up breaking things so make sure to back up your stuff and check your script's side effects for any undesired behavior (did you forget -a to tee? if so, you just overwrote the file...)

main olive
#

yea im doing all of this on a test server

#

that i just deployed

#

i'll do man tee

boreal kestrel
#

@main olive

To make it so that ONLY User1 and User2 can modify File1.txt, you'll need to create a supplementary group for example User1AndUser2. Then you'll need to add both users to it by using usermod -aG User1AndUser2 User1 User2. Read the documentation by doing man usermod and googling. "usermod" means "user modify".

After you've created the supplementary group and added both users to it, make sure that the file's owned by one of the users and the supplementary group. Try chown User1:User1AndUser2 File1.txt ("change ownership"). Then make sure that the group permissions include writeable: chmod g+rw File1.txt (change modification permission). You should also do this for all of the parent directories of File1.txt: if someone else owns a parent directory then it can be possible for them to get around your desires.

As far as making it so someone can modify a file but not delete it... I'm not sure that's 100% possible using normal filesystem permissions

#

@slow coral I'm not familiar with setxkbmap nor with zsh. I would venture a guess though that if it's a local login shell (eg, not via ssh) then you're probably running setxkbmap prior to the X11 session being available. Otherwise hopefully someone else can help

slow coral
#

ohhh that would make sense, if that is the case is there a different file i should be putting the command in?
originally i had it in .xinitrc but that didn't seem to get sourced either and the research i did for that one was confusing but seemed like it just doesn't? i dont know

boreal kestrel
#

huh today I learned .xinitrc is a thing

main olive
#
sudo adduser dom --gecos "First Last,RoomNumber,WorkPhone,HomePhone" --disabled-password
echo "dom:mypasswordhere" | sudo chpasswd
adduser dom sudo

echo 'dom ALL=(ALL) NOPASSWD:ALL' | sudo EDITOR='tee -a' visudo
sudo -u dom sudo mkdir /home/dom/domnag
sudo -u dom sudo apt install python3-pip
sudo -u dom sudo apt install python3-venv
sudo -u dom  python3 -m venv /home/dom/domnag/venv
sudo -u dom source /home/dom/domnag/venv/bin/activate
#

sudo: source: command not found fatal: could not create work tree dir 'domNAG_Gen': Permission denied sudo: pip: command not found

warped nimbus
#

source is a bash built-in I believe

#

What are you trying to accomplish by attempting to activate the venv like that?

#

Do you want the venv to always be active for that user?

main olive
#

I'm trying to clone a repo, and then install the requirements in the venv

warped nimbus
#

I see. I'm not sure how to do that as another user besides using sudo -u dom bash -c "source ... && ..."

boreal kestrel
#

echo 'dom ALL=(ALL) NOPASSWD:ALL' | sudo EDITOR='tee -a' visudo

This will still create a file named visudo. It will not edit your sudoers file and will not send the data through the visudo command.

main olive
#

wait rlly?

#

cus it worked i think

#

i haven't entered a sudo password after that

boreal kestrel
#

sudo is usually set up to cache your password after first use. The cache is typically something like 5, 10, or 15 minutes. So as long as your user has permission to run the command and the command has permission to do whatever it needs to do under the user selected, then it will "work". But the side-effects might not be what you wanted.

main olive
#

I didn't type it once though

#

only to ssh in

#

does that still count?

boreal kestrel
#

On some operating systems, the default user is part of wheel or admin group, and often those group don't need to type a password to use sudo. See:

# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL

or something similar in your sudoers file, and the list of groups you have under groups

#

Actually sudo EDITOR='tee -a' visudo won't even create a file named visudo. I didn't see you're using EDITOR=, I thought it was just tee -a visudo

main olive
#

so uhhhh what do i do to actually do it?

boreal kestrel
#

Oh wow, you're right. Today I learned visudo reads stdin

main olive
#

lol

#

so uh how do i fix that

boreal kestrel
#

sudo -u dom source /home/dom/domnag/venv/bin/activate will try to run source command which should be found within your ${PATH}. But since source is actually a bash builtin (and not an executable file in ${PATH}), it won't be found; therefore the error sudo: source: command not found is emitted. Even if it did work, it would only work in the context of that specific sudo -u dom. It won't be used by the current user running the script. It won't be used by any subsequent commands invoked after source finished. What do you want to have happen?

sudo -u dom sudo mkdir /home/dom/domnag
Why are you running sudo twice? Once as whoever's running the script and then once more as dom? Specifically, running sudo mkdir /home/dom/domnag will make root user and group own /home/dom/domnag. So that's the source of your permission denied error from vent..

I don't see where you're running pip.

main olive
#

for the sudo -u dom source /home/dom/domnag/venv/bin/activate I basically want to activate the venv and then install the requirements of my requirements.txt

for sudo -u dom sudo mkdir /home/dom/domnag I tried sudo -u dom mkdir /home/dom/domnag but I got the same error. I'll try it again though.

sudo -u dom source ./home/dom/domnag/venv/bin/activate
sudo -u dom git clone https://myusername:mypassword@github.com/dominuslabs/myreponame.git
sudo -u dom pip install -r /home/dom/domnag/myreponame/requirements.txt```
#

thats the part of the script to use pip install

warped nimbus
#

I already explained you could do it with bash -c

main olive
#

why is it bash -c?

#

what does that do?

warped nimbus
#

It executes commands in a subshell

#

the subshell will be under the dom user

main olive
#

oh

boreal kestrel
#

I don't use venv so I'm familiar with its use. I imagine you might try something like sudo -u dom bash -c 'source /home/dom/domnag/venv/bin/activate; python3 -m pip install requirements.txt'

Use man bash, then press forward-slash / and search for -c. Then read the documentation about it.

warped nimbus
#

You pass all the commands as a string following -c

main olive
#

sudo -u dom bash -c "source ./home/dom/domnag/venv/bin/activate"

#

oh ok

boreal kestrel
#

You'll need to make sure that anything which needs to be run with /home/dom/domnag/venv/bin/activate sourced will also need to run in that same bash -c

main olive
#

oh

boreal kestrel
#

Also ./home/dom/domnag/venv/bin/activate with the period at the front is probably not what you want

main olive
#

yea i just tired that

#

tried*

#
sudo -u dom bash -c 'source /home/dom/domnag/venv/bin/activate; git clone blah blah ;python3 -m pip install requirements.txt'```
#

would the git clone have to be in the venv as well?

warped nimbus
#

No

main olive
#

oh ok

boreal kestrel
#

Do you want git clone to inherit whatever environment variables you get from sourcing the script?

main olive
#

i suppose not

#

sudo -u dom git clone https://:@github.com/dominuslabs/domNAG_Gen.git domnag sudo -u dom bash -c 'source /home/dom/domnag/venv/bin/activate;python3 -m pip install requirements.txt'

#
bash: /home/dom/domnag/venv/bin/activate: No such file or directory
The directory '/root/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/root/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting requirements.txt```
boreal kestrel
#

Great password

main olive
#

thx

boreal kestrel
#

Are you still using sudo -u dom sudo mkdir ?

main olive
#

nope

boreal kestrel
#

Is Github denying your git clone request? Are your credentials correct? Personally, I use SSH instead of HTTPS but that requires a little more setup.

You might want to try getting your script to work as your current user before you try running it as someone else

main olive
#

all the info is right

green sigil
#

Hello I'm writing the following script in bash ```#!/bin/bash

#Display the UID and username of the user executing this script

#Display if the user if the vagrant user or not

#Display the UID.
echo "Your UID is ${UID}"
#Only display if the UID does NOT match 1000.
UID_To_TEST_FOR="1000"
if [["${UID}" -ne "${UID_To_TEST_FOR}"]]
then
echo "Your UID does not match ${UID_To_TEST_FOR}."
exit 1

#Display the username.

#Test if the command succeeded.

#You can use a string test conditional

Test for != (not equal for the string.)```

#

I'm getting this error line 30: syntax error: unexpected end of file

#

I'm not sure why I don't see any errors

#

I even have the quotes and stuff matching in the code that's active

#

can anyone help out ?

#

I have also chmod 755 this code to execute it

warped nimbus
#

You forgot fi at the end of the if block

green sigil
#

Oh ok ty

main olive
#

How do I grep multiple delimiters? I need to get f1 to f3

formal schooner
#

@main olive example?

main olive
#

So, I have to output ONLY the date and time of when the firewall started. The line shows the date and time and then says Starting firewalld and some other stuff

#

How do I cut the entire line and just show the date and time (they are at the start of the line)

#

Format: Feb 11 14:10:29 server0 systemd: Starting firewalld - dynamic firewall daemon...

formal schooner
#

@main olive

echo 'Feb 11 14:10:29 server0 systemd: Starting firewalld - dynamic firewall daemon...' | cut -f1-3 -d' '
bitter pasture
#

how can I run multiple lines with one linux command

main olive
#

separate them with ;

bitter pasture
#

but like

#

I want it to be an alias too

#

so I can simply type git-oop and it will upload the files to the designated git server

#

or git-ds for a different server

main olive
#

sure, alias cmd="command1 && command2"

#

or maybe set up a bash function

bitter pasture
#

dunno how to use bash, so Ill probs go with the first option

#

ty!

main olive
#

np bro

bitter pasture
#

oops sorry one more question. what file do I put aliases in, and in what dir? @main olive

main olive
#

alias commands need to be run for each instance of the shell. Luckily, the commands in ~/.bashrc get executed every time you open a new instance of bash, so you can just stick them in there

gilded basalt
#

Typically ~/.bash_aliases

main olive
#

oh yeah, that's a thing as well

bitter pasture
#

oh neat ty!

#

is it possible to put in arguments as well?
so for git, you usually put an overview of what was edited, so I'd do
git commit -m "did things to the file"
is there a way to put "did things to the file" in the command too?

main olive
#

that will require a bash function

bitter pasture
#

fun times. guess Ill have to look that up

#

where do I start

main olive
#

it's really easy though, really recommend making one

#

just Google for "bash function syntax" I guess

#

you'll have to stick them in .bashrc as well

bitter pasture
#

neat. ty!

#

does this look functional? (I dont really want to go through the hassle of attempting to commit to git and having to mess with stuff quite yet)

main olive
#

$1 only takes the first word, you probably want, what was it, $@ (?)

#

otherwise, yeah, looks good to me

bitter pasture
#

oh, will it not take a whole sting as an arg?

#

ex: "hello there"

#

if I put it in quotes

main olive
#

it just takes "hello", it's a positional argument

#

oh uh

#

not sure about quotes

bitter pasture
#

oh maybe it will take ""hello"

#

with two quotes in the front

main olive
#

test it out I guess

#

haven't written bash scripts in a while, have to get back on that

bitter pasture
#

no worries, thanks for the help :)

main olive
#

πŸ‘

formal schooner
#

you only need to add the remote once

#

and you only need to use -u once

#

fyi

#

and you can git commit -a -m instead of git add . && git commit -m

#

well i guess git add . also adds untracked files

main olive
#
sudo apt install python3-pip
sudo apt install python3-venv
python3 -m venv domnag/venv
cd domnag
sudo bash -c 'source venv/bin/activate'
git clone https://myusername:mypassword@github.com/myusername/myreponame.git
cd myreponame
pip install requirements.txt```
#

./deploy.sh: line 13: pip: command not found

#

I thought I activated my venv and it would find the command

formal schooner
#

@main olive

sudo bash -c 'source venv/bin/activate'
  1. why sudo
  2. this spawns a new shell, runs source venv/bin/activate in the new shell (not your current shell), then exits
#
sudo apt install python3-pip
sudo apt install python3-venv

cd domnag
python3 -m venv ./venv
source ./venv/bin/activate

git clone https://myusername:mypassword@github.com/myusername/myreponame.git
cd myreponame
pip install -r requirements.txt
main olive
#

oh

#

ok that worked

red raven
#

I am applying for new jobs and one of the jobs asked what unix platforms I have used. I strictly use unix daily on ubuntu but that is it, I am guessing then I never used a true unix platform?

upbeat badger
#

GNU is not Unix

red raven
#

unix-like

#

its just not purely unix

robust cave
#

well if you use Ubuntu daily, then if they ask what unix-like platforms have you used, why not answer Ubuntu?

red raven
#

because they didnt say unix like

#

they stated: What is your experience with Unix? What Unix platforms have you worked with?

#

I was just saying GNU is unix-like so I probably wouldn't say I had no experience?

jagged orbit
#

didnt ubuntu switch a few times between versions?

robust cave
#

you could have asked? I don't know anybody working on strictly Unix systems nowadays

red raven
#

I just said I use unix-like operating systems

#

man i look at all these job posting and I am overwhelmed by the amount of things that are required. I have a bachelors but damn

#

feel out of my league most of the time

#

Still applying though because fuck it

main olive
#

@formal schooner "well i guess git add . also adds untracked files"

#

git add -A

warped nimbus
#

@red raven I think some "true" Unix OSs still out there today are Solaris and AIX

#

It's not out of the question for them to ask if you had experience with that

#

But a lot of the time they really mean unix-like

red raven
#

I figured. Most servers I know are ran on Linux based OS's, which I still believe Unix - like is basically Unix

main olive
#

How can I set a password for a directory using a shell script

robust cave
#

you would need a third party tool to encrypt and decrypt the directory

#

your shell script would also have to prompt the user for the key, if not there would be no point to it

main olive
#

Oof

main olive
#

alright since i can't do that

#

is it possible to change the root password using a script?

boreal kestrel
#

anything you can do as a user

#

you can do in a script

main olive
#

So im trying to make a ssh banner script

#
#!/bin/zsh
PURPLE="\033[01;35m"
RED="\033[01;31m"
NC="\033[00m"

echo -e "${PURPLE}β–ˆβ–ˆβ•—  β–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ•—   β–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—"
echo -e "${PURPLE}β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β•β•β•β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β•β•β•β–ˆβ–ˆβ•”β•β•β•β•β•"
echo -e "${PURPLE}β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β–ˆβ–ˆβ–ˆβ–ˆβ•”β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—  "
echo -e "${PURPLE}β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β•  β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•‘β•šβ•β•β•β•β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β•  "
echo -e "${PURPLE}β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘ β•šβ•β• β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—"
echo -e "${PURPLE}β•šβ•β•  β•šβ•β• β•šβ•β•β•β•β•β• β•šβ•β•     β•šβ•β•β•šβ•β•β•β•β•β•β•β•šβ•β•β•β•β•β• β•šβ•β•  β•šβ•β•β•šβ•β•β•β•β•β•β•β•šβ•β•β•β•β•β•β•"
echo -e "${RED}             ~Debian~                          "
echo -e "${PURPLE}--------------------------------------------------------------------"
echo -e "${NC}"
#

I chmod'd it and set it as the banner and tried logging back in, and I got this:

#
| #!/bin/zsh
| PURPLE="\033[01;35m"
| RED="\033[01;31m"
| NC="\033[00m"
|
| echo -e "${PURPLE}β–ˆβ–ˆβ•—  β–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ•—   β–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ
> β•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—"
| echo -e "${PURPLE}β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β•β•β•β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β•β•
> β•β–ˆβ–ˆβ•”β•β•β•β•β•"
| echo -e "${PURPLE}β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β–ˆβ–ˆβ–ˆβ–ˆβ•”β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ
> β•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—  "
| echo -e "${PURPLE}β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β•  β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•‘β•šβ•β•β•β•β–ˆβ–ˆ
> β•‘β–ˆβ–ˆβ•”β•β•β•  "
| echo -e "${PURPLE}β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘ β•šβ•β• β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ
> β•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—"
| echo -e "${PURPLE}β•šβ•β•  β•šβ•β• β•šβ•β•β•β•β•β• β•šβ•β•     β•šβ•β•β•šβ•β•β•β•β•β•β•β•šβ•β•β•β•β•β• β•šβ•β•  β•šβ•β•β•šβ•β•β•β•β•β•
> β•β•šβ•β•β•β•β•β•β•"
| echo -e "${RED}            ~Debian~      "
| echo -e "${PURPLE}-----------------------------------------------------------
> ---------"
| echo -e "${NC}"
#

how do I fix this

#

it executes fine on its own,

main olive
#

how can I get my Ip address, and then use it in this echo command:```

#get my ip address here
echo "Your IP address is (put IP address here)"

#

echo -e β€œYour IP address is ${ifconfig en1 | awk '{ print $2}' | grep -E -o "([0-9]{1,3}[.]){3}[0-9]{1,3}"}”

#

I’m not at all sure about that, but try it

robust cave
#

ifconfig is outdated, you can get ip addresses using ip addr, grep/awk the stuff you want from that

grave jolt
#

@main olive banners cant have escapes or code in them

robust cave
#

this works for me

ip addr | awk '/inet/ && !/host/ { print $2 }'

@Dom.#6904

main olive
#

I get back 172.105.154.24/24 2600:3c02::f03c:91ff:feb5:4673/64 fe80::f03c:91ff:feb5:4673/64 (this is a server)

robust cave
#

how many interfaces do you have?, you might also want to not show the ip? (I'm not a security person)

main olive
#

Its just a test VPS

#

so I'll be destroying it soon

robust cave
#

excluding lo, how many items show up when you do ip addr

main olive
#

Just 1 (eth0)

#

well fuck

robust cave
#

eeeeh I don't know much networking stuff, that's an ethernet interface, and you have 1 ipv4 address and two ipv6 addresses

#

and that's about the extent of my knowledge

sharp shell
#

sounds right, that's pretty common for vps'

main olive
#

well not having color in the banner sucks

robust cave
#

the point is it's possible to have multiple ip addresses

sharp shell
#

yep

robust cave
#

@main olive you can absolutely have color in the banner, you just need a third party tool like toilet or lolcat (that I remember) on the machine that you're ssh'ing to, then pass whatever text you want coloured to those programs

main olive
#

would I do that with a bash script?

robust cave
#

it's definitely possible

main olive
#

@ Mili#7773 banners cant have escapes or code in them

wait so I can have a bash script as a banner

robust cave
#

how are you putting the banner

main olive
#

Kosayoda how can I just select the first line of the output then? I'm relatively sure that the first line will always be the IPv4

#

curl ifconfig.me

#

by editing the /etc/ssh/sshd_config file to point to the file containing the banner

#

I found that on StackExchange and it seems to work

robust cave
#

@main olive that does a network request, just so we're clear

#
ip addr | awk '/inet/ && !/host/ { print $2; exit }'
#

will get you the first one

main olive
#

Are there any downsides to using a network request?

robust cave
#

man awk is great

#

I'll let xx talk about it, they're way more knowledgable

main olive
#

Because I realize that when I did ip addr | awk ... I get 172.105.154.24/24. I have no idea what the /24 is and where it came from and whether it changes for each VPS I use

#

/etc/motd supports ansi colours @main olive, but that's usually shown after authenticating

sharp shell
#

that's the range, Dom

main olive
#

Oh

#

that's the subnet indicator, yeah

#

/24 is 255.255.255.0

sharp shell
#

/24 means that the first 24 bits of the IP address are the network numbers, the last is the host address

#

yeah

main olive
#

The idea behind getting the IP is so I can use it in my Nginx config file I'm writing with a bash script (just to provide some more perspective)

#

@main olive putting that script into /etc/motd still shows fucked up output

#

you need the output of the script (including the ansi escape sequences) in there

#

so you need to run the script, save the output, guarantee that the colours still work (with cat) and then use that as the motd

#

there's also another motd utility which executes scripts as well, but it varies by distro

#

Ubuntu uses it to show news and some stats to the user upon logging in

#

oh shit thanks

#

got it to work?

#

yeah thanks a lot

#

np dude

#

xx should i use curl ifconfig.me or ip addr | awk to get my IP? i'm going to write this to my nginx config file and ip addr , like you said, returns the ip with a subnet indicator. Which one would be the "best" one to use?

#

do you want your public IP or the IP that your own network gateway has assigned you?

#

the first gets the former, the other one the latter

#

Public IP

#

then you should use curl

#

Oh alright.

#

although if you have dig, I recommend this

#

dig +short myip.opendns.com @resolver1.opendns.com

#

it's way faster

#

and relies on opendns, which might be more reliable than ifconfig.me

#
IPAD="$(curl ifconfig.me)"
echo "server {
    listen 80;
    server_name ${IPAD};
    location /static {
        alias /static;
    }
    location / {
        proxy_pass http://localhost:8000;
        include /etc/nginx/proxy_params;
        proxy_redirect off;
    }
}" >> /etc/nginx/sites-enabled/domnag```
#

Is that valid?

#

server_name does not want quotes

#

Oh because its already in quotes from the echo?

#

brb gotta go to work

#

@main olive yep

#

πŸ‘Œ

#

Thanks

#

have fun at work

#

usually do πŸ˜‰

green sigil
#

is anyone free to help on a weird a unix issue I'm having ?

#

Here is my code. ```#!/bin/bash

#This script creats a new user on the local system.

You will be prompted to enter the username (login), the person name, and a password.

The username, password, and host for the account will be displayed

#Make sure the script is being executed with super user privileges.
if [["${UID}" -ne 0]]
then
echo 'Please run with sudo or as root.'
exit 1
fi

#Get the username(login).
read - p 'Enter the username to create: ' USER_NAME

Get the real name (contents for the description field).

read -p 'Enter the name of the prson or application that will be using this account: ' COMMENT

#Get the password.
read -p 'Enter the password to use for the account: ' PASSWORD

#Create the account.
useradd -c "${COMMENT}" -m ${USER_NAME}

Check to see if the useradd command succeeded.

WE don't want to tell the user that an account was cretaed when it hasn't been.

if [[ "${UID}"]] -ne 0 ]]
then
echo 'The account could not be created.'
exit 1
fi

set the password

echo ${PASSWORD} | passwd --stdin ${USER_NAME}

if [[ "${?}"]] -ne 0 ]]
then
echo 'The password for the account could not be set.'
exit 1
fi

#Force password change on first login
passwd -e ${USER_NAME}

#Display the username, password, and the host where the user was created.
echo
echo 'username:'
echo "${USER_NAME}"
echo
echo 'password:'
echo "${PASSWORD}"
echo
echo 'host:'
echo "${HOSTNAME}"
exit 0```

#

I'm getting errors with the following line : if [["${UID}" -ne 0]] then echo 'Please run with sudo or as root.' exit 1 fi

#

Here is the error : [[:1000]]: syntax error: invalid arithmetic operator ( error token is "]]")

#

I'm not sure what exactly is wrong