Command Line

Subscribe to Command Line feed
This is for anything regarding the command line, in any operating system. All questions (including dumb ones), tips, and interesting programs/console applications you've found or made yourself are welcome. Linux / BSD / OSX / Windows CLI apps or questions or comments, we're happy to take them all!Command Line
Updated: 40 min 35 sec ago

Fuzzy file finder and file type execution

Thu, 11/15/2018 - 14:52

Hi :)

I _really_ miss spotlight in OSX and in Linux it seems fzf is the most minimalistic way to have the same functionality. Currently, I use an alias for "nvim $(fzf)" but of course the file always has to be a text file. What if I wanted to open a pdf, flac, video-file or something like that? Is it possible to set that up?

submitted by /u/lastchansen
[link] [comments]

Are there any actively-maintained, console-focused distros for i486/i586?

Wed, 11/14/2018 - 18:41

Hey folks,

With the handwriting on the wall in regards to core kernel support for early 32-bit CPUs, and a variety distros having announced they will be following suit, I'm curious to know if there are any non-abandoned, moderately-active distros or distro forks out there that are focused on 32-bit, pre-i686 based sub-archs. I am aware of Debian LTS, but am looking for something with a bit more of a focus than this.

Barring that, is anyone aware of any non-server-centric, console-focused distros, more generally?

submitted by /u/aperezbios
[link] [comments]

Running WebSockets as a service automatically

Wed, 11/14/2018 - 04:55

I need to run the PHP WebSocket scripted in PHP 24/7/365 as a service automatically whenever,

the server restarts/stops/starts the process. The process must invoke automatically

Suppose if we access the test.php from the browser i.e.,

it starts and continues to run with port 8080.

However, suppose if we try to terminate the process by killing with the below commands

# kill $(lsof -t -i:8080) # lsof -i:8080

So that it must be invoked automatically

If we plan to run as a scheduler with a cron job for every second or particular day.

How do I compromise with the compensation beared by the server uptime as well as server downtime? or

if none of the options are left suppose if we try to run the cron job for every second,

how do I script the code, whether the WebSocket is running with port 8080,

if not execute this script by shell_exec() or via exec() commands

Here is the code for test.php

Here is the code for test.php <?php # The maximum execution time, in seconds. If set to zero, no time limit is imposed. set_time_limit(0); # Make sure to keep alive the script when a client disconnect. ignore_user_abort(true); error_reporting(E_ALL); ini_set('display_errors', 'On'); error_reporting(-1); // reports all errors ini_set("display_errors", "1"); // shows all errors ini_set("log_errors", 1); ini_set("error_log", "/var/www/vhosts/"); echo "Script start at: " . date('h:i:s') . "\n"; exec('bash -c "exec nohup php websocket_server.php >> /var/www/vhosts/ 2>&1 &"'); shell_exec('nohup php /var/www/vhosts/ 2>&1 >> /var/www/vhosts/ &'); echo "Script end at: " . date('h:i:s'); ?>

So How do I need to run the process as a service automated when HTTP server starts?

With the help of a supervisor or systemd. which launches it in the background and keeps it running. What should be the Linux commands that need to be executed via SSH ?

submitted by /u/nishanth_29
[link] [comments]

A quick bash function to get a small bit of data from the command line to my phone

Tue, 11/13/2018 - 17:57
$ type ytqr ytqr is a function ytqr () { x="ytqr.png" ; \ qrencode -l H -o "$x" "$*" && \ timeout 30s display -resize 300 -border 100 "$x" && \ rm "$x" } $ ytqr

ytqr is short for "YouTube QR", but it could be used for any small amount of data besides the video you wish to watch on your phone while you are on the head. The string goes into your clipboard using the tools I use.

I had to install qrencode, and timeout is a command I was - until recently - unaware of. (At a job a decade ago I instead coded it in a crufty way into a function in my scripts.)

This function gives me just about enough time to unlock my phone, launch the Barcode Scanner app (f-droid app store) and read the QR code. Then it goes away by itself or can be dismissed with a click.

Options on display make the barcode easy to read, even with a dark background, add error correction, and make it large enough to scan quickly with my cheap phone.

I though about Bluetooth links or ssh into the phone, but this is what I came up with.

How do you get a small amount of data, maybe an 11 digit base-64 number (where the case of the letters actually matters quite a bit and transcribing by hand is a PITA) from your desktop to your phone? Am I missing something obvious?

submitted by /u/sticky-bit
[link] [comments]

Recommendations for Virtual Online CLI's (Powershell/Linux)?

Tue, 11/13/2018 - 12:01

I've been taking an online course and I've been wanting to practice. I've been doing a lot of practicing at work and I was wondering if anyone had any suggestions. Currently, I'm using JSLinux and just the powershell on my computer but I'm leery about messing up something being a beginner.

I'd appreciate any help. Thanks,

submitted by /u/cryptoalt1234567
[link] [comments]

Atom Text Editor (Windows Version) what do you think?

Tue, 11/13/2018 - 03:41

Atom seems an easier to Setup and Hack than Sublime. it's doing some heavy lifting but it's relatively lightweight. To ice the cake windows version is quite handy as Vim is a giant pain to run in PS and CLI. It seems to run smooth unless you are working with large JSON files.


submitted by /u/Helmcame2317
[link] [comments]

A bash script to find all files over a given bitrate and then transcode them to a lower one would be great!

Mon, 11/12/2018 - 14:17

For example, you have a bunch of mp3s. Some of them are 320kbps. You want to make them, and only them, smaller in order to fit more music into a phone. So the script would find all mp3 files with 320kbps and transcode them to Opus 128 or 160kbps.

submitted by /u/skidmark-steve
[link] [comments]

Guide needed

Mon, 11/12/2018 - 01:33


As the title says, I want to learn the use of the command line/bash. Do you know any good guide for this purpose? Thanks for the tips! Corrently using Mint19 cinnamon if thats relevant.

submitted by /u/ktbr90
[link] [comments]

WINDOWS 10 CMD: 'Program' is not recognized... ERROR

Sun, 11/11/2018 - 14:28

Hi all

I want to create a hard link for chrome so I can let chrome use my AMD Radeon Vega gpu instead of the standard Intel one.

I'm trying to do this command:

C:\Program Files (x86)\Google\Chrome\Application>mklink /H gpu-chrome.exe chrome.exe

However I get the error:

'Program' is not recognized as an internal or external command,

operable program or batch file.

Things I tried to solve this:

- Run CMD as admin

- Make sure %SystemRoot%\System32 is in the System Path of Environment Variables

- Get full management of the map Program Files (x86)

- Searched the hell out of Google

Maybe CMD has problems with spaces between words.

Could someone please HELP ME!

Thanks in advance

Side note:

I also can't force CMD to start in '' C:\ '' .

In properties I changed the 'Start in'.However CMD always start with ''C:\WINDOWS\system32>''.I made a hyperlink for cmd also but it still didn't work.

At the moment I'm getting around this problem by using the command: C:\Windows\System32\cmd.exe /k "cd c:\"

submitted by /u/gimmesnoww
[link] [comments]

Remove words and phrases from lines

Sat, 11/10/2018 - 01:43

I have a file whose contents are as follows:

Tue Oct 9 06:00:04 2018 ab=980849 First line of text Tue Oct 9 06:00:04 2018 ab=980878 Second line of text: Tue Oct 9 06:00:04 2018 ab=980885 (a) first sub-heading Tue Oct 9 06:00:04 2018 ab=980891 (b) second sub-heading Tue Oct 9 06:00:04 2018 ab=980897 (c) third sub-heading Tue Oct 9 06:00:04 2018 ab=980902 (d) fourth sub-heading Tue Oct 9 06:00:04 2018 ab=980906 (e) fifth sub-heading Tue Oct 9 06:00:04 2018 ab=980911 (f) sixth sub-heading Tue Oct 9 06:00:04 2018 ab=980915 (g) seventh sub-heading Tue Oct 9 06:00:04 2018 ab=980920 (h) eighth sub-heading Tue Oct 9 06:00:04 2018 ab=980925 (i) ninth sub-heading Tue Oct 9 06:00:04 2018 ab=980929 (j) tenth sub-heading

I wish to remove the word starting with Tue till the ab=6-digit-number from the above lines. The result should be:

First line of text Second line of text: (a) first sub-heading (b) second sub-heading

if possible, preserve the indentation of (a) first sub-heading and (b) second sub-heading

What is the neatest and simplest method to accomplish the above? Is it possible to use sed in this case?

I appreciate your help in this matter.

submitted by /u/w0rKb33s
[link] [comments]

Using Find & Findstr throws an error as bad command in MS Dos

Sat, 11/10/2018 - 01:25


Is their any alternative code we use in Dos rather than find and findstr?. Please let me know. Also if you ve a complete list of commands for dos, do send me d link.

Thank you

submitted by /u/prashants985
[link] [comments]

For small command line programs, python beats haskell.

Fri, 11/09/2018 - 07:46

For small programs, python is ok. For large programs, haskell disciplines your code with its ghc compiler. I like discipline.

For scripting usage, haskell becomes unwieldy because stack scripts usually require minutes of compilation for the first time and stack adds 0.3~0.5 second to the startup time.

Python is born for scripting.

submitted by /u/MilkroTik
[link] [comments]

What are good alternatives to bash?

Thu, 11/08/2018 - 23:30

I wanted to change things a bit.

  • fish
    • I tried fish, and I liked it.
  • xonsh
    • I haven't tried it. It allows python expressions. Someone told me it is poorly written.
  • elvish
    • I haven't tried it, yet.
  • zsh
    • It seems very complex. I want a simpler alternative to zsh.
  • ...
submitted by /u/MilkroTik
[link] [comments]

Enlist loaded kernel modules with description and dependency

Thu, 11/08/2018 - 07:35

awk '{print $1}' "/proc/modules" | xargs modinfo | awk '/^(filename|desc|depends)/'

submitted by /u/unixbhaskar
[link] [comments]