#unix
1 messages Β· Page 30 of 1
a thing that should tell us what this lib is linking against
lid sharpops
whats lid lol
lld is a utility for listing what a binary links against
FUCK YOU
what
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
why does it link against musl
But I can't see what here would be breaking it
install the musl libc then
tar?
install muscl libc
This was working up untill I tried to change shit
So the executable is missing shit?
and most linux systems wants GNU libc
thats minimization
Its GAY
@sage solar 2 circleci builds later, and it works
ty!
nix's useless unix trivia ftw
π π¦
not useless
It's also the reason why manylinux wheels do not work on Alpine
π
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
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
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
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+"
@main olive and what nvim version have you got?
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
Except that that is the python neovim package and not neovim itself
That's not your neovim version
Probably nvim --version
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
Well there is your issue
Yeah. Just figured it out
I thought it was the neovim in python
Thank you. I was stuck on this for like 3 days
Haha no problem
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
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
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
@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...
thnx for the advice
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.
@potent orchid thats odd. how did you install anaconda
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
not sure if I understand you correctly. Could you give a small input/output example?
For example in a text file:
cat file | sed -r 's/search/replace/g' | grep -n replace | cut -d ':' -f 1 ?
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
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?
This works if i run the commands right after each other only if i actually write to the file
I see. So you want to:
- append data to file
- sort data after append
- fine where the new data should be added?
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
cat <(cat <(echo "Alpha") <(echo "Omega")) <(echo "Beta") | sort | grep -nP "^Beta$" | cut -d ':' -f 1
figure out the caluclation through output
replace <(cat <(echo "Alpha") <(echo "Omega")) with the name of your file
sort and grep are fast π
that gave me every strings line number
Is your line unique?
I'd use grep -Fnx 'Beta' instead, in the command above. Fixed string full line match.
Huh, learn something new everyday
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
you could just remove the -i and write to a different file name with > text2.txt
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
awesome! thats exactly what I wanted. get the line number without actually writing to the file
thanks for your help guys!
yw
[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
The bad file descriptor means that you're doing something with a file or socket which has been closed
Look at listener and verify that it is a valid listening socket.
whats listener?
lol thats from gunciorn not my file 
(it's probably a socket or something that holds a socket, and it probably needs to be told to listen() before it will work)
its pointing the /home/dom/domalert/venv/lib/python3.6/site-packages/gunicorn/workers/base_async.py
as the file for the error
Have you read gunicorn's documentation and/or code around the error?
Tried but I didn't see anything that applied to my code
https://github.com/benoitc/gunicorn/blob/master/gunicorn/workers/base_async.py#L33-L41 looks like the listener is already closed when it reaches that code in gunicorn. If I were you, I'd ask for help from the gunicorn guys. Looks like github shows the line on 38 instead of 39 though, so your version isn't the same as master. Might try updating first.
π
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.
Are you sure you're reaching the point where you call driver.quit() when you're launched by cron?
Related reading: https://stackoverflow.com/a/1506914/1111557
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().
yea, looks like the process was terminating early. Not sure why it was only happening with cron though, will investigate. thanks!
@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)
Ahh I thought when a child process dies, the parent inherits any descendents of the child
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)
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
"subreaper" new term to me. Thanks!
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
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?
trying it now
I think best practice is putting it in the conf.d folder. sites-* is an apache thing that was adopted for convenience
conf.d is simpler if you use something like ansible, sites-x when you do it manually
I read it in a guide somewhere
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?
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
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 π€
keep in mind writing/accessing many tiny files is significantly slower than one large of the same total size
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
Β―_(γ)_/Β―
Is there a tool to copy terms to translations (gettext) from bash?
what are you trying to achieve?
@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
yeah thats true
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?
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
I would guess ubuntu probably has the best hardware support
Xubuntu is probably a good option
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
centos is like redhat/fedora isn't it?
@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
better than fedora?
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
@main olive isnt KDE somewhat of a learning curve though?
definitely not
well my 70-something grandmother picked up Plasma pretty instantly
if there is a learning curve, it's not very steep
That's good to know
Okay ill try out Kubuntu then. Thanks
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?
no sorry
@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
How can I install a windows-like gui to a google cloud compute server? :D
@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...
What would be the real reasons that would make it a bad idea? :D
install an X server on your computer, install XFCE on the server
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...
that too
If you just want a UI to use for admin tasks check out Cockpit
@gritty bobcat you install a graphical interface and set up X forwarding
@torn snow well im setting up a vpn and ya
Yeah if it's for admin config definitely check out Cockpit, it's built for this type of stuff
wdym @torn snow
Like for admin tasks
Cockpit is a web UI that's designed for managing servers
Cockpit makes it easy to administer your GNU/Linux servers via a web browser.
i think you're responding to the wrong dude @torn snow
Dammit
π€¦
You'd think I'd learn at this point that late night discord generally ends badly
:D happens to the best of us
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?
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
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
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?
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
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.
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]"
for example, for ubuntu: http://packaging.ubuntu.com/html/packaging-new-software.html
ok
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
@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?
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
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'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)
Oof lockups suck
But for nvidia, does rpmfusion not ship them for RHEL?
oof yeah they don't for 8 yet
@main olive So if i use sudo cp /path/to/executable /usr/local/bin no evil can be injected
alias cp=dosomethingelseinstead
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?
I've seen history issues kinda like that in bash but not sure about the cause
@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
@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
i meant, no evil could easily be injected
so i would just directly point the path to the executable.
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
Is there possibly any way to call the executable as a command without moving it to /usr/bin/sudo
???
Don't move ANYTHING to /usr/bin/sudo, please...
that would overwrite the sudo binary, which is not good
ok
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
@main olive alias sudo="echo hello world"
@boreal kestrel also probably wouldn't work as alias is scoped to the current shell only
well, it depends I guess
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
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'
Anything I should pay special attention to when trying to install Linux to a Windows laptop for dual boot?
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.
only thing I have noticed, idk if there is more.
Really hoping it doesnt mess with Windows10 EFI bootloader, cause i heard dual boot can be a pain
it went smooth for me when installing ubuntu from a usb to a windows 10 dual boot.
alright here goes nothing then
@raw tapir seem to be stuck in Grub loader :/
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)
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
@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
This was just a small thing for WSL, not enough of an issue to warrant it
I have Manjaro on my laptop at home
why is linux better
Depends on your usecase
Linux is powerful because it gives the user a lot of control
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?
ok found the issue
python 3.7 doesnt have a folder for some reason
but py 3.6 does
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

Eventually!
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?
You have spoken to wise men.
What questions do you have.
ubuntu is a linux distribution.
Ask for reasons to use, it's fast on older hardware, a lot of devtools are avaiable and fit in well with the environment.
ohk
You can use windows subsystem for linux to use a linux terminal on windows.
oh
There are a few of those avaiable in the windows store.
what perks i get with that
what can i do with linux terminal
like whats the reason people download it
It's mainly for running linux software iirc. I've never used it on windows myself.
okay
Git bash will work everywhere and for anything, it's not just for git
yeah, git bash is just an msys2 instance with git installed
its using cygwin is it not... (or is that just the optional bash shell git provides iirc)
@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
Okay
@echo tinsel install the python3.6-distutils package (or something like that)
Checkout pip's documentation about its installation then π€
@echo tinsel this is sort of what virtual environments are for
@echo tinsel should be python3-distutils instead IIRC, try that?
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
if that doesn't work, I personally would just use pyenv to manage my Python installations, here: https://github.com/pyenv/pyenv
environments really are the way to go
how would you create a virtual environment using Python 3.6 if you don't have Python 3.6 though? Can it be done?
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
why wouldnβt you use 3.7 though?
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 ?)
@rich lynx the same compared to what?
Compared to a Linux computer I think @formal schooner
would have to wait for clarification from the original commenter to make sure
For example if I use a command in ubuntu
Is the command the same on linux mint ?
(Sorry for being unclear)
essentially, yes. Linux Mint specifically is a derivative of Ubuntu, so they are pretty similar for the most part
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
@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
Guys who's using manjaro xfce?
<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 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.
Ok, I'll give that a go
hmm
@gritty bobcat Have you tried
sudo apt --fix-broken install
Also use their repositories
Thanks, I fixed the issue, ty for the help 
np, I would love to help anybody in trouble*
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
First, are you sure /usr/bin/pip is for python 3?
there are 3 python installed, lol
That doesn't mean much
how to check that
Lots of distros come with python 2
which pip
Or pip --version
mine came with 2.7 and 3.6 and then i installed 3.7
You probably want top be using python3 -m pip install ...
okay
okay i got the prob
pip is not of 3.7
i did sudo apt install python-pip
before
python3-pip, maybe
okay
Still, you'd likely need to use pip3 or what I showed above
you probably don't want to remove it
okay
update-alternatives can change what the default pip points to
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
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?
Maybe
I glossed over the fact you also have 3.6
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?
yes
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
nvm
@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
@blazing wolf python3 -m venv <myenvname>
will create a py3 virtualenvironment
so when you activate it
interpreter will be set to py3
If my system (Arch) offers packages also available through pip, which should i prefer? For example, pipenv
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
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
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
there's actually a note on the archwiki:
--ignore-installedis necessary until https://github.com/pypa/pip/issues/3063 is resolved (otherwise pip skips the install in the presence of an earlier --user install).
And in the context of arch, that could happen because other packages could depend on a python package
actually this seems to be for installing system packages through pip install while already having installed them with --user, not arch python-X packages
Don't arch packages go through pip anyway?
Ok well pipenv uses setup.py
IDK if that's the same thing as pip
i think setup.py build adds to pip? i haven't looked into it all that much
i think, yeah. but honestly, i haven't been good about using envs and have just been installing globally
β
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
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
good thing i don't use virtualenvs π
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
@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
@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)
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
Pyenv is almost a must imo
Poetry and pipenv do have some overlap, but they are for different things.
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
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.
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.
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
@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 π
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 :)
I didn't mean it in that sense, but okay cool π
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 ?
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.
if you're using requests or something similar, you might try reading this stackoverflow, https://stackoverflow.com/a/21868231/1111557
You could also use something like nethogs to monitor your network IO
Hey, is there anyway to get the AST that bash builds for each command ?
you mean for builtins like pipes, boolean logic, redirections, etc?
I imagine you have to go hacking the source tbh
Yes @main olive
Tell me more @uneven silo !
ill have to find it agaih
@uneven silo interesting, did you reimplement the bash operator logic in python?
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
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''
whats the proper way of adding a new user via a bash script on Ubuntu?
@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 π¦
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
What do you think this does? sudo -u myuser bash -c 'cd ${HOME}; mkdir dummydir'
Figured it out?
I realized there was prob no clean way to do what I meant
What do you mean?
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
funny enough useradd is provided by BusyBox in alpine and it's about as feature-different as can be expected for any BusyBox implementation
yeah, but, busybox
Yeah it is adduser in busybox
huh, til
yeah docker run --rm -ti alpine useradd --help -> executable file not found in $PATH
no usermod https://busybox.net/downloads/BusyBox.html
@granite sentinel Found it finally. It's called bashlex
@main olive Yea I started some stuff. Here's a couple of the more interesting parts of the bot
https://gitlab.a-sketchy.site/AnonymousDapper/dash/blob/master/core/context.py
https://gitlab.a-sketchy.site/AnonymousDapper/dash/blob/master/dash.py#L155
Thanks man! This should be really useful
Especially since the ast can be dumped in a very readable format
the ast it makes isn't great, but with a little work, its manageable
clean kode
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
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
Hi can I ask questions here about a virtual box set up ?
You can. Is it somewhat related to Unix? VirtualBox can run on and provide guests to many operating systems
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
That's the http request types curl supports
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?
I mean in python you could just use the requests library instead of curl
Requests is the http Lib which you'll find has the best user interface in python yes
requests all the way
unless you're doing async stuff
@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...?)
@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
Interesting. What's myuser's home directory? Does it have correct ownership and permissions?
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)```
@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.
sudo adduser myuser
sudo -u myuser mkdir /home/myuser/dom
``` ended up working for me
/hom ?
lol
thx
is there a way where I don't have to type the sudo password when running sudo commands for the first time?
sudo visudo /etc/sudoers -> man sudoers
look for NOPASSWD and make sure to read and think about any security impact
uh maybe it is
honestly I don't edit sudoers often
to edit the sudoers via a bash script its like echo "myuser ALL=(ALL) NOPASSWD:ALL" >> sudo visudo
lol no
try it, it will be harmless. you'll create a file named sudo in your current directory π
π
>> in bash will append the pipeline's stdout to the file, creating the file if necessary
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?
What do you mean?
like it thought i was trying to append the text to a file named sudo?
Yes
This appears to be fairly comprehensive: https://unix.stackexchange.com/q/159513/128494
Take a look at the Pipe Operator
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?
Then also compare to the Redirection Operators
ubuntu 19.04, zsh, idk what else you'd want to know?
@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
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
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
huh today I learned .xinitrc is a thing
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
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?
I'm trying to clone a repo, and then install the requirements in the venv
I see. I'm not sure how to do that as another user besides using sudo -u dom bash -c "source ... && ..."
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.
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.
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
so uhhhh what do i do to actually do it?
Oh wow, you're right. Today I learned visudo reads stdin
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.
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
I already explained you could do it with bash -c
oh
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.
You pass all the commands as a string following -c
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
oh
Also ./home/dom/domnag/venv/bin/activate with the period at the front is probably not what you want
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?
No
oh ok
Do you want git clone to inherit whatever environment variables you get from sourcing the script?
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```
Great password
thx
Are you still using sudo -u dom sudo mkdir ?
nope
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
all the info is right
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
You forgot fi at the end of the if block
Oh ok ty
How do I grep multiple delimiters? I need to get f1 to f3
@main olive example?
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...
@main olive
echo 'Feb 11 14:10:29 server0 systemd: Starting firewalld - dynamic firewall daemon...' | cut -f1-3 -d' '
how can I run multiple lines with one linux command
separate them with ;
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
np bro
oops sorry one more question. what file do I put aliases in, and in what dir? @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
Typically ~/.bash_aliases
oh yeah, that's a thing as well
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?
that will require a bash function
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
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)
$1 only takes the first word, you probably want, what was it, $@ (?)
otherwise, yeah, looks good to me
oh, will it not take a whole sting as an arg?
ex: "hello there"
if I put it in quotes
test it out I guess
haven't written bash scripts in a while, have to get back on that
no worries, thanks for the help :)
π
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
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
@main olive
sudo bash -c 'source venv/bin/activate'
- why sudo
- this spawns a new shell, runs
source venv/bin/activatein 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
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?
GNU is not Unix
well if you use Ubuntu daily, then if they ask what unix-like platforms have you used, why not answer Ubuntu?
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?
didnt ubuntu switch a few times between versions?
you could have asked? I don't know anybody working on strictly Unix systems nowadays
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
@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
I figured. Most servers I know are ran on Linux based OS's, which I still believe Unix - like is basically Unix
How can I set a password for a directory using a shell script
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
Oof
alright since i can't do that
is it possible to change the root password using a script?
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,
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
ifconfig is outdated, you can get ip addresses using ip addr, grep/awk the stuff you want from that
@main olive banners cant have escapes or code in them
this works for me
ip addr | awk '/inet/ && !/host/ { print $2 }'
@Dom.#6904
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)
how many interfaces do you have?, you might also want to not show the ip? (I'm not a security person)
excluding lo, how many items show up when you do ip addr
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
sounds right, that's pretty common for vps'
well not having color in the banner sucks
the point is it's possible to have multiple ip addresses
yep
@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
would I do that with a bash script?
it's definitely possible
@ Mili#7773 banners cant have escapes or code in them
wait so I can have a bash script as a banner
how are you putting the banner
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
@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
Are there any downsides to using a network request?
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
that's the range, Dom
/24 means that the first 24 bits of the IP address are the network numbers, the last is the host address
yeah
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 π
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
