Questions tagged [portability]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
3 votes
1 answer
221 views

Portable Linux emulator on Windows?

In a Windows computer where you don't have permission to install software, does Windows Linux subsystem, cygwin or any complete or partial Linux shell, utility or API emulator have portable versions? ...
user avatar
  • 89.7k
12 votes
6 answers
1k views

What's the best way to trace all the changes I've made to my system files over the years?

As I imagine a lot of Linux users do, over the years I've followed the advice of countless different threads, blogposts, videos etc. and made various changes to system files in order to improve my ...
user avatar
  • 137
0 votes
1 answer
38 views

terminfo/termcap `tput bold`/`tput md`: portability of bold text

Suppose I have the following color support in one of my portable shell scripts: #!/bin/sh set -o nounset tput_init_linux () { set_fg_color='tput setaf'; reset_color=$(tput sgr0 2>/dev/null); } ...
user avatar
5 votes
1 answer
287 views

Difference between posix_fadvise and readahead

As per manpage, readahead is Linux specific: CONFORMING TO The readahead() system call is Linux-specific, and its use should be avoided in portable applications. and posix_fadvise is portable: ...
user avatar
8 votes
1 answer
488 views

On what UNIX-like system / filesystem is the st_blocks field returned by stat() not a number of 512-byte units?

I always assumed the st_blocks field returned by stat()/lstat()... system calls and which du uses to get the disk usage of files was expressed in 512 bytes units. Checking the POSIX specification, I ...
user avatar
2 votes
0 answers
40 views

Does POSIX specify sed -E? [duplicate]

sed uses basic regular expressions (BRE) by default. Some implementations offer an option to switch to extended regular expressions instead. GNU sed introduced the -r option to do so in version 3.01 ...
user avatar
  • 551
0 votes
1 answer
434 views

Kali Linux on portable SSD with data persistence

I need to setup a portable kali-linux environment that I can boot on any available computer. I don't want to use a virtual environment because I would need to download VMware on the host computer, ...
user avatar
4 votes
2 answers
1k views

Who is responsible for providing `set -o pipefail`

I want strict mode in my scripts. I would also appreciate portability. set -o pipefail seems compulsory. Yet shellcheck(a static linter) is unhappy that "In POSIX sh, set option pipefail is ...
user avatar
  • 2,643
1 vote
2 answers
69 views

Portable name of C++ compiler (and linker)

cc is the POSIX name of the C compiler. Is there a general name of the C++ compiler (and linker). Notice that g++ also adds some libraries, that will not be included when using plain gcc or ld.
user avatar
2 votes
0 answers
62 views

Is there any difference between Ubuntu and Centos 7 when running su -c “my command” “someuser” ?

I tried below command in both Ubuntu and Centos 7: su -c "./bin/server" swrun and I found it's started process by root in Ubuntu, but started process by swrun in Centos 7. I used service ...
user avatar
-2 votes
1 answer
126 views

Is there any guide how to write bash scripts compatible with both CentOS and Ubuntu

I am simplifying my scenario here. I've built a series of bash scripts and tested them under Ubuntu. I want to make sure my scripts (bash syntax) work the same under CentOs. Is there any guide how to ...
user avatar
2 votes
1 answer
179 views

Why is not 'test -z =' an error after all?

I have a book that stated: "....For example, if the shell variable symbol contains an equal sign, look at what happens if you try to test it for zero length: $ echo $symbol = $ test -z "$...
user avatar
  • 161
1 vote
0 answers
84 views

Why do BSD and GNU grep give different results here?

I distribute a slightly modified version of a public CSV file. To generate the modified CSV file I use a short one-line grep command: grep -Ev '^([A-Za-zA-Za-z]|[0-90-9]*),' input.csv Actual project ...
user avatar
  • 171
1 vote
0 answers
77 views

making sqlcmd self-contained so it would be possible to run without installation, for CentOs

I am trying to make a bash script to connect to remote SQL server with sqlcmd in the devp machine, as I have admin privileges, runs smoothly but I NEED (and capitals because it is imperative) to build ...
user avatar
0 votes
3 answers
205 views

sed portability: extended regex vs. backslash

We can write the next command in two ways: # using extended regex $ echo foobar | sed -E 's/(foo)(bar)/\2\1/' barfoo And: # using backslashes $ echo foobar | sed 's/\(foo\)\(bar\)/\2\1/' barfoo ...
user avatar
2 votes
0 answers
418 views

Portable way to set custom URL scheme handler for all users

I already know how to create a custom URL scheme and set its handler using xdg-utils: xdg-settings set default-url-scheme-handler name handler.desktop However, the command affects only the current ...
user avatar
11 votes
2 answers
2k views

How portable is a gzip file over 4 GB in size?

To backup a snapshot of my work, I run a command like tar -czf work.tgz work to create a gzipped tar file, which I can then drop in cloud storage. However, I have just noticed that gzip has a 4 GB ...
user avatar
  • 213
0 votes
1 answer
141 views

Are octal escape sequences more portable than hex ones for shell scripts

As part of a scheme for writing shell code that's capable of processing arbitrary data, I was looking for a way to convert null bytes to some other character. I found that tr requires arbitrary bytes ...
user avatar
  • 3,408
0 votes
1 answer
244 views

How to make a shell script as portable as possible (POSIX and non-POSIX)

Situation: Writing a shell script to do some stuff across multiple shells Problem: While Bourne-compatible shell scripts (bash, ksh, ash, zsh, etc) are easy to be made portable (just make sure the ...
user avatar
0 votes
1 answer
60 views

Is it safe to hardcode /etc/ path for configurations in an application I'm contributing to?

The application I'm contributing to requires configuration files as a part of its operation. This is currently placed within the root directory of the application. If I followed the FHS, the config ...
user avatar
  • 109
0 votes
0 answers
673 views

How to test a binary, to see if all shared library dependencies, are satisfied?

I have a program which I compiled on an earlier version of Fedora which suddenly broke after an upgrade. I was running an older version of Fedora at the time which had stopped receiving updates; so I ...
user avatar
  • 2,145
-2 votes
1 answer
79 views

Linux off a Flash Drive

I want to run Linux off of a flash drive. I'm already dual booting Windows 10, and Ubuntu on my laptop, and have burnt the mint ISO onto a flash drive. Every time I load it live, it takes me to a ...
user avatar
  • 1
2 votes
1 answer
123 views

process list with quoted arguments, portably

How can an original command issued at the command line be acquired without using proc or any other non standard tool? When printing a process list using ps, the arguments passed in to initiate the ...
user avatar
2 votes
0 answers
266 views

Portable way of finding files whose birth date is after a given timestamp

According to How to find creation date of file?, in Linux filesystems, such as ext4, Btrfs and JFS, that store the file creation time (aka birth time), it is possible to display the file birth time (...
user avatar
  • 3,623
0 votes
1 answer
763 views

How to remap network interfaces on boot time?

It turns out that I'm trying to create a portable distro while getting prepared for any kind of hardware failure. I'm creating (or restoring) a Debian distro by multistrap (or from my backups) and ...
user avatar
  • 1,937
1 vote
4 answers
3k views

What is the most portable shell, and relevant best practices to follow? [closed]

I have been enthusiastic to shell scripting for some months, and found that the codes I write (in bash) do not work in some machines. This is very disappointing. I realize that I should have learned ...
user avatar
  • 351
5 votes
2 answers
474 views

Does FreeBSD contain multiple variants of basic regex?

grep and sed are both described as using "basic regex" ("BRE") by default. BRE is well described here. But consider this output: # echo ' aaaaa ' | grep '\(aaaaa\|bbbbb\)' aaaaa # echo ' ...
user avatar
  • 1,111
0 votes
1 answer
569 views

MX Linux Not giving me the USB option while trying to install on it

I have make bootable USB of MX Linux with the help of RUFUS software. Now when I am trying to install on USB it does not show me partition to install it while I am booting live setup . The choose the ...
user avatar
  • 13
2 votes
2 answers
117 views

Why is the which command so hard to eradicate? [closed]

I'm coming from places like Why not use "which"? What to use then? and https://stackoverflow.com/questions/592620/how-to-check-if-a-program-exists-from-a-bash-script and am myself a long-...
user avatar
  • 6,930
4 votes
0 answers
472 views

Convert an existing customised Debian 10 Installation to Live ISO

Can someone help please? I already did some research and found: Linux Respin completely messed up my system when trying to install dependencies (removed a lot of packages I needed) - at least I am ...
user avatar
  • 41
0 votes
0 answers
31 views

Is it possible to have bash but not awk? [duplicate]

Here on Stack Exchange we often see answers on bash questions, that use tools other than the bash language, such as awk, sed, grep, etc. These tools are specific in POSIX, so they should be ...
user avatar
  • 2,852
2 votes
1 answer
922 views

POSIX and Portability | shell scripts | grep -s, grep -q

I am all in for portability in regards to shell scripts. But I am unsure if I am overdoing it right now. In this example, we have a function called confirmation, which accepts the very first ...
user avatar
5 votes
1 answer
395 views

Does POSIX make not support globs in prerequisites?

I was reading the POSIX 7 Make definition, and I've noticed that prerequisites are almost always described as “files”: The make utility examines time relationships and shall update those derived ...
user avatar
  • 337
0 votes
1 answer
401 views

Wildcards/Globbing: Are character ranges problematic?

In The Linux Command Line William Shotts claims that character ranges can be problematic. See the relevant excerpt below, emphasis is mine. Character Ranges If you are coming from another Unix-like ...
user avatar
  • 167
1 vote
1 answer
989 views

Portable way to run command without PATH from bash script

cron calls my bash script (it's a backup script) with a very sparse PATH of /usr/bin:/usr. As a result, while a line like lvcreate --size 1G --snapshot ... works just fine when I run the script from ...
user avatar
3 votes
2 answers
278 views

Recommended way of checking only one running service?

I am writing a shell script to check if mongod server is running and if not, to start it. To acheive that I am using the below command: systemctl is-active --quiet mongod This does the job as ...
user avatar
29 votes
3 answers
3k views

Porting Linux to another platform requirements [closed]

I know that Linux is available and has been ported for many different platforms such as for X86, ARM, PowerPC etc. However, in terms of porting, what is required exactly? My understanding is that ...
user avatar
6 votes
1 answer
2k views

How does glibc within a Docker image survive different container host kernels?

Docker containers share the kernel of the host, but they do include their own applications and libraries. Is it correct that glibc is one of these libraries? If so, how come there is no problem of ...
user avatar
  • 163
8 votes
5 answers
3k views

Portable check empty directory

With Bash and Dash, you can check for an empty directory using just the shell (ignore dotfiles to keep things simple): set * if [ -e "$1" ] then echo 'not empty' else echo 'empty' fi However I ...
user avatar
3 votes
1 answer
330 views

All-round 100% portable terminal color support check

Test for terminal color support using tput #!/bin/sh colors_supported() { command -v tput > /dev/null 2>&1 && tput setaf 1 > /dev/null 2>&1 } I am currently using ...
user avatar
3 votes
0 answers
158 views

What subset of Linux does recent WSL support? [closed]

I know well Linux but nothing about WSL or Windows. I'm using Linux since 1993, but I never used Windows (and probably won't use it before my retirement, e.g. before 2024, so I am likely to never use ...
user avatar
6 votes
3 answers
9k views

Do all different Linux distributions have the same command lines? [closed]

Do all different Linux distributions have the same command lines? What I want to know is the same command line works for all kinds of Linux distributions (CentOS, Fedora, Ubuntu, etc.) or whether they ...
user avatar
6 votes
2 answers
149 views

What makes a Linux distro portable?

What could possibly prevent me from detaching my current hard disk from the laptop and buy a new laptop, install the disk and resume from where I left? In other words, what prevents my current Debian ...
user avatar
  • 1,937
7 votes
3 answers
4k views

Can I read a single character from stdin in POSIX shell?

Only read -r is specified by POSIX; read -n NUM, used to read NUM characters, is not. Is there a portable way to automatically return after reading a given number of characters from stdin? My usecase ...
user avatar
  • 611
0 votes
1 answer
57 views

Portable way to run a simple script at startup

I'm trying to run a script at startup as root. (Just sets up a root-owned directory in /tmp). Currently, I'm using this script to set up the boot hook and it appears to get the job done: #!/bin/sh -...
user avatar
  • 26.1k
-3 votes
1 answer
171 views

Is pstree available on all Unices and Linux operating systems? [closed]

Is it a standard command that I can be assured is available on all standard-conformant operating systems? If so, what is the guarantee given by the relevant standard? Is it, conversely, a non-...
user avatar
3 votes
0 answers
75 views

What's wrong with putting do on the same line as for? [duplicate]

While reading about 11.12 Limitations of Shell Builtins I came across the following: To loop over positional arguments, use: for arg do echo "$arg" done You may not leave the do ...
user avatar
  • 32.6k
5 votes
2 answers
551 views

Is word splitting a part of POSIX?

I know that Bash has word splitting but zsh doesn't, and I'm not familiar with others(csh, tcsh, ksh, etc), but I was wondering if it is a part of any standard. In other words, does sh have word ...
user avatar
2 votes
1 answer
816 views

How to change the RS variable in AWK between files in a portable way

While looking at another question, I came across a problem I couldn't solve generally for awk, where if an awk program takes two files (i.e. to read entries from the first into an array to compare ...
user avatar
  • 864
2 votes
1 answer
652 views

Availability of deprecated egrep and fgrep commands

Quite often I've seen answers mentioning that egrep is grep -E or fgrep is grep -F and using egrep or fgrep in their answers, even though these are technically deprecated. So I was wondering if ...
user avatar
  • 864