/r/unix

Photograph via snooOG

About

/r/unix is a subreddit for Unix and everything related to Unix.


Rules

/r/unix is a pretty chill place:


Related subreddits:

/r/unix

21,176 Subscribers

3 Comments
2024/05/09
20:07 UTC

3

Need help from any existing Java21+ users on aarch64

Basically, for the past week I have been trying to get java 21 running on an aarch64 machine, which wouldn't normally be a problem, BUT the machine just happens to be a NanoPi R4S, which has no output so the only OS you can use on it is open/friendlywrt. That kinda sucks tho, since no official java binaries exist for it, you can't compile java for it since you don't have java installed, and if you just get a generic aarch64 package off the official java servers (This), i get the following error: "..../bin/java: cannot execute: file not found"

This happens with any command that is java

So what i need help with is basically getting java 21 to run on the machine, so as extra info here's the wiki and specs of the R4S for those who aren't familiar with it: NanoPi R4S Wiki ; NanoPi R4S Specs

UPDATE: Thanks for the help, i don't know how i forgot that other OSes exist i can use for this so i'll look into that later, for now i managed to get Azul Zulu running on it. (By managed i mean it worked instantly)

5 Comments
2024/05/06
22:29 UTC

6

Grouping and Compressing all files in a directory.

Hi!

I’m trying to do an automated job in shell, basically I have a directory with 1000+ files and each day some other files are added.

I’m trying to create a script that runs periodically and clean up the directory and backup the files.

The script will take some arguments, like: SourceDirectory DestinationDirectory FilenameMatcher SkipCriteria RetentionCriteria

And basically, what I want to achieve is:

  • Read all the files in the SourceDirectory and the modification date of each of them, as long as they match some FilenameMatcher.
  • If the modification date is before SkipCriteria (Example: 1 Monthly = skip last month) ignore them. So I keep the most recent logs accessible.
  • Everything else should be processed, I would like to create a compressed file for a specific RetentionCriteria (Example: 24 Monthly = Compress grouped by month and keep the last 24). Once compressed, move to a backup directory.

Any suggestions in how to achieve this?

6 Comments
2024/05/04
23:25 UTC

11

What are cool things to do with UNIX sockets?

I'm currently exploring reasons why or why not to mount the /var/run/docker.sock UNIX socket into a Docker container.

This made me curious, what are some cool tricks or projects any of you all have done using either the Docker socket or any other UNIX sockets.

6 Comments
2024/04/29
19:29 UTC

2

unix terminal

hi guys i wanna know how to customize my terminal and make it beautiful like unixporn guys, i see a lot of amazing terminal and i see links they provide to make your like them but i can not cuz im beginner in these stuffs. they provide dofitles and some stuffs like that but dont know how to use .

5 Comments
2024/04/27
17:33 UTC

2

How to get rid of blank lines in the beginning of a file?

Some config files have between 1 and 5 blank lines at the top before any comments or settings are shown. How can I use 'sed' to delete blank lines until text appears?

I do not want to delete any blank lines once the text starts though.

15 Comments
2024/04/21
20:24 UTC

9

The Hyra Operating System

Hyra is a work in progress Unix-like operating system in development with the eventual goal of being used frequently and potentially daily driven by myself. Hyra is apart of the OSMORA (osmora.org) project which has also been created by me.

https://github.com/sigsegv7/Hyra/

4 Comments
2024/04/20
22:52 UTC

22

The standard text editor

I've used vi and emacs forever but recently needed to use ed to script up some file changes. While I wouldn't want to use it full time, I have found three usecases where it's worth considering:

  • the common one -- if you've any scripts that invoke an editor to generate input for further processing, ed is a less jarring workflow than having an app take over the terminal.
  • setting it as the editor for git commit messages works surprisingly well. I tried it as a lark and decided I'm going to keep it. Not because it's noticeably faster but it encourages writing clearer content.
  • resolving conflicts. it works well for formulaic, targeted edits and allows you to see the files that need changes. That said, unlike the previous item, I'll probably continue to use vi for this.

Two other comments:

  • once I got used to delete lines at the end of the file first, I found it intuitive.
  • it's improving my skill with vi.
11 Comments
2024/04/18
00:35 UTC

7

Why does ctrl + c take so long for a sudo password prompt?

If I enter a correct password in the sudo password query, it does not take a tenth of a second until I can continue my activity as super user. But if I cancel the sudo password query on my Arch Linux system, it takes longer.

Why is that?

I can understand if the password prompt takes a long time to reject an incorrect password. This may be due to the algorithm, or to prevent brute force from being possible so quickly, idk.

8 Comments
2024/04/17
15:17 UTC

7

Fun with sed

I've been trying to get a file like the following:

hello
world
README
boo
hoo
README
psg
dortmund
README

to look like the following:

README
hello
world
README
boo
hoo
README
psg
dortmund

The closest I've gotten so far is the following command:

sed -n '/README/!H;/README/G;/README/p'

which leads to the following:

README

hello
world
README

hello
world
boo
hoo
README

hello
world
boo
hoo
psg
dortmund

After screwing around too much, I ended up using awk but it feels like I'm "this close" to having it work.

5 Comments
2024/04/16
23:30 UTC

1

Remove directories after loop

Hi,

Hoping someone with true unix knowledge can help with what will inevitably be something straightforward, but I can't seem to fumble my way through.

I'm just wanting to remove the $ORIG_DIR once the loop has run through a single and remove the $ALAC_DIR if the original files are .mp3 and it's finished the loop?

SOURCE_DIR="$(cd "$(dirname "${dirs[0]}")"; pwd)/$(basename "${dirs[0]}")"
SOURCE_DIR=$(dirname "$SOURCE_DIR/temp") # this fixes . and ./
HIRES_DIR="$(cd "$(dirname "${dirs[1]}")"; pwd)/$(basename "${dirs[1]}")"
HIRES_DIR=$(dirname "$HIRES_DIR/temp") # this fixes . and ./
LORES_DIR="$(cd "$(dirname "${dirs[2]}")"; pwd)/$(basename "${dirs[2]}")"
LORES_DIR=$(dirname "$LORES_DIR/temp") # this fixes . and ./
find "$SOURCE_DIR" \( -iname '*.flac' -or -iname '*.mp3' \) -type f -print | while read -r FILE
do
  ORIG_DIR=$(dirname "$FILE") 
  BASE=$(basename "$FILE") 
  BASE=${BASE%.*} 
  AAC_DIR=${ORIG_DIR/$SOURCE_DIR/$LORES_DIR}
  ALAC_DIR=${ORIG_DIR/$SOURCE_DIR/$HIRES_DIR}
  mkdir -p "$AAC_DIR" "$ALAC_DIR"
  AAC_FILE="$AAC_DIR/$BASE.m4a"
  ALAC_FILE="$ALAC_DIR/$BASE.m4a"
  if [[ (! -f "$AAC_FILE" && $FILE == *.flac) ]]; then
	ffmpeg -hide_banner -i "$FILE" -c:v copy -b:a 256k -c:a aac "$AAC_FILE" </dev/null &&
	ffmpeg -hide_banner -i "$FILE" -c:v copy -c:a alac "$ALAC_FILE" </dev/null
  elif [[ (! -f "$AAC_FILE" && $FILE == *.mp3) ]]; then
	ffmpeg -hide_banner -i "$FILE" -c:v copy -b:a 256k -c:a aac "$AAC_FILE" </dev/null
  fi
done
rmdir "$ALAC_DIR"
rm -Rf "$ORIG_DIR"

8 Comments
2024/04/16
22:17 UTC

11

Show r/unix: Unix Notes

Hello,

I am working on compiling a notebook of practical mini essays, notes, and code examples elucidating how Unix and the POSIX API works.

There is a learning curve for understanding how to use and code within Unix. These notes are used to make the individual topics more accessible. I have notes on a handful of networking concepts, including some small C programs demonstrating the POSIX. I'll eventually add more Unix topics, as well as more code samples for Awk, C, sh, etc.

If anyone is interested in contributing or learning more about Unix, please visit unix-notes.

2 Comments
2024/04/16
18:33 UTC

7

Best way to learn kernel development?

So I'm a 13yo looking to learn the very basics of kernel development, withought any jargon whatsoever. I know some C and python but forgot quite a lot. What's the best online resource to learn kernel development. I won't be able to read physical books. Online resource, please.

10 Comments
2024/04/06
13:48 UTC

66

SCO legal team to aisle one please. SCO legal team, aisle one.

3 Comments
2024/04/04
01:22 UTC

12

smenu v1.4.0 released.

smenu started as a lightweight and flexible terminal menu generator, but quickly evolved into a powerful and versatile CLI selection tool for interactive or scripting use.

smenu makes it easy to navigate and select words from stdin or a file using a friendly text-based user interface. The selection is printed to stdout for further processing.

Tested on Linux and FreeBSD but should work on other Unix as well.

It is available here: https://github.com/p-gen/smenu

Changes: https://github.com/p-gen/smenu/releases/tag/v1.4.0

2 Comments
2024/04/01
22:25 UTC

21

Prof. David Brailsford discusses Ken Thompson's ACM Turing Award acceptance paper "Reflections on Trusting Trust." Seems on point with backdoor discovered in xz/lzma

0 Comments
2024/03/30
13:56 UTC

11

sdf.org?

Anyone know what happened? It seems like it's gone.

8 Comments
2024/03/22
02:03 UTC

0

yes, sed works with ' and " under windows

This apparently upsets a lot of people here.

Using windows with 4 shells (cmd, powershell, TCC, and bash), sed absolutely works with both ' and "

People need to grow up about this and stop insisting otherwise.

1 Comment
2024/03/21
15:48 UTC

3

SSH key basic question

Hi folks, why does the first command work but the second does not? Permissions on the server are 700 for /home/me/.ssh and 600 for /home/me/.ssh/authorized_keys . /home/me/.ssh/authorized_keys is a copy of /root/.ssh/authorized_keys, and I've restarted sshd. Am I losing my mind?

me@home ~ % ssh me@my.server
me@my.server: Permission denied (publickey).
me@home ~ % ssh root@my.server
Welcome to Ubuntu 22.04.4 LTS (GNU/Linux 5.15.0-101-generic x86_64)

9 Comments
2024/03/21
03:14 UTC

5

I’m nerd, not a tech. Looking for recommendations for a book to learn *nix/ FreeBSD /*BSD

I’m in a strange spot from playing around so much where I believe I’m a little past the basic stage but not quite at advanced from Google and what not. -I’m looking for a good handprint , preferably with labs, to build a solid foundation- I don’t don’t work in tech I’m just a nerd, not even a gamer.

  • I have TrueNAS (scale not core) on HW up and running and several VM’s running on it and my win10

I can SSH to all of them now, I can move around in directories, I’m a little familiar with VIM, and I’m all over the place. I have FreeBSD, Debian, ghost, all running.

I just need a solid starting point and a road map to go from the left to right, and I believe FreeBSD looks like a great place to start.

Please advise on a book for a working man and nerd. I’m tired of PDF’s and switching between windows.

Some practicals would be nice as I have no real reason, at this juncture, to run or use any of it.

Thank you all in advance!

11 Comments
2024/03/20
15:12 UTC

5

sed stopped working with emoji?

UPDATE: SEMI-SOLVED: Problem is specific to a recently-upgraded cygwin installation. Even though the versoin of sed.exe is the same on 3 machines, it is broken on the 1 machine that upgraded cygwin. But that same machine can get it working by running out of the cygwin\bin folders on the other 2 machines. I probably have to revert my cygwin upgrade, even though the sed version is the same. Suspect DLLS or some other b.s.

UPDATE 2: Reverting the cygwin\bin folder fixed the problems. AND YES, SED WORKS WITH ' AND " FOR ME, EVEN THOUGH I RUN WINDOWS. I'm not sorry that makes you uncomfortable.

ORIGINAL MESSAGE:

Any idea why I woke up this morning to my sed no longer working with emoji?

It's cygwin sed, but it's the same cygwin sed as my other 2 machines.

All 3 worked with emoji just fine. For months!

Woke up today, 1 machine is not working.

TCC v31 on 2 of the machines — one working, one not (lol)

TCC v28 on 1 of the machines — working

This is driving me crazy. I'm trying to add emoji around certain words. It works for months on 3 machines, then ... stopped this morning on one machine.

< 7:37a> <15%> C:\>echo gOlIaTh |:u8 sed -e 's/goliath/GOLIATH/gi'GOLIATH

< 7:36a> <10%> C:\>echo gOlIaTh |:u8 sed -e 's/goliath/🦇GOLIATH🦇/gi'/cygdrive/c/cygwin/bin/sed: -e expression #1, char 1: unknown command: `''

EDIT: I should mention sed works fine with ' or " in my situation. The problem is NOT that i simply used the wrong quote. I wish it were that simple. This is a situation that is was working on 3 computers for 3 months then borked on 1 of the machines overnight.

29 Comments
2024/03/19
11:51 UTC

12

Switching to BSD?

Hello I am mostly a Mac OS user and I know that Mac OS is basically a fork of BSD. My secondary computer runs Linux although I am wondering if it's worth installing FreeBSD on it instead. I know that there is more software support on Linux, and I will miss tools like lsblk. Another thing that is keeping me on the fence is if FreeBSD is really that different compared to Mac OS. I know there will be differences due to the open source and software packaging. Although can I get most of the experience on my Mac?

17 Comments
2024/03/17
23:33 UTC

3

Postfix/Dovecot Setup (Early Stage), Someone willing to sanity check my thinking on this?

I just want to make sure I have my thinking on this correct. We're configuring a mail server for our network with some specific requirements.

  1. The actual mail content must be held in the OZ (maybe RZ, management hasn't decided on the classification of the incoming mail yet), not in the PAZ
  2. The received mail will be accessed by another server using IMAPS in the OZ
  3. We are allowing mail to only be sent within our organization, only allowing received mail from particular internet mail addresses/domains (all else would be dropped in the PAZ)
  4. Preference toward low hardware resource requirements and updates easily
  5. We'll be using secure protocols the entire way

My thinking on this was the following:

PAZ

Postfix Satellite here that will be used to relay email received from the internet into the OZ

Configure satellite to whitelist specific domains/addresses and drop everything else

Configure satellite for SMTPS

OZ

Postfix Internet Server Configure Mailboxes for virtual users here, Configure for SMTPS

Dovecot Configure for IMAPS

This is the basic EARLY outline I have right now for how I'm going to do this. It's been a while since I configured a mail server that wasn't "Out of a Box". We may need an additional hop if they decide they want the data stored in our RZ instead (I would just setup another satellite in our OZ for this, we don't want any RZ DNS info on the public side so it would have to go to OZ first).

Thank you for the sanity check!

10 Comments
2024/03/13
11:42 UTC

Back To Top