date int64 1,220B 1,719B | question_description stringlengths 28 29.9k | accepted_answer stringlengths 12 26.4k | question_title stringlengths 14 159 |
|---|---|---|---|
1,561,493,692,000 |
i need to find the last 15 users that logged in to the system.
i know there are commands like 'w' or 'who' or 'users' but as much as i know those commands refer only to users currnetly logged-in.
but i need the user names of the 15 last active users - even if they already logged out...
the man of users say:
users - p... |
The last command lists the last logged-in users. The data comes from /var/log/wtmp and can be limited to n-lines with the -n <number> option. Other options allow one to select records "since" or "until" particular login times.
If the wtmp file doesn't exist, no logging occurs. To create the file if it doesn't exist... | find last 15 users that logged in - even if some of them already logged out |
1,561,493,692,000 |
I am trying to find all the files in my directory that does not contain the letters a,b or c; why does this command not work?
ls *[!abc]*
example: eg: MATCH: xyz, dkh, file, foo; NOT MATCH: bar, bxc, azi,csk
|
Your command does something very similar to what you want: it expands to the list of filenames that are not exactly: a, b, or c. If you test, you see:
$ touch a b c d
$ ls *[!abc]*
d
But if you create another file and re-test:
$ touch argh
$ ls *[!abc]*
argh d
To exclude file names that contain those characters anyw... | Find all the filenames in this directory that do not contain 'a' 'b' or 'c' in their name [duplicate] |
1,561,493,692,000 |
I was updating my laptop when an electrical blackout happene. I restarted and try to use again sudo dnf update, but this happened:
The downloaded packages were saved in cache until the next successful transaction.
You can remove cached packages by executing 'dnf clean packages'.
Error: Transaction check error:
file... |
If you have 64x System, you should not install 32x packages in. Looking to you picture they are starting to create conflicts.
| How do I repair a bad update in Fedora 28?(edited) [closed] |
1,561,493,692,000 |
I need to reset router and I just get access with ssh to raspberry in local network with router. I'm trying with elinks and w3m browser but I can't see any option, maybe because the router's control panel is javascript page...
Can you recommend any option to access the option to restart router from the web control pa... |
I had a similar problem before and I fixed it by creating an SSH tunnel using Putty.
| How to reset router through command line browser? [closed] |
1,561,493,692,000 |
Attempting to discover a command to copy files if the destination's (not source's) file has not been modified in the last hour.
|
I know of no command that will precisely match your requirement. Something like this should work (remove the --dry-run when you're sure you're happy with the result; replace the --verbose with --quiet if you want it to run more silently):
src=/path/to/source
dst=/path/to/target
comm -z -23 \
<(find "$src" -ty... | Copy files from one directory to another, ignoring files where the destination's file has been modified in the last hour? |
1,561,493,692,000 |
How can I handle the attributes (read, write, hidden ...) of an executable program of Windows (*.exe) from the Linux terminal (command line)?
thanks in advance
Update:
For further clarification, suppose I have a hidden executable in Windows (NTFS). Start with a Linux LiveCD, mount NTFS partition and I want to remove t... |
When the filesystem is mounted with NTFS-3G, the setfattr command should let you change extended attributes, which are stored in system.ntfs_attrib_be.
First, query the existing attributes with getfattr:
$ getfattr -n system.ntfs_attrib_be -e hex file.txt
# file: file.txt
system.ntfs_attrib_be=0x00000022
Then set the... | changing attributes of Windows programs from Linux |
1,528,387,444,000 |
As in how can I get the *.foreground color value obtained with xrdb -query assigned to a variable in the script.
I'm trying to get both background and foreground colors into two variables that will be passed to another program as parameters.
|
Figured it out, kinda. When using pywal we can import the colours from its cache, like this:
#!/bin/sh
. "${HOME}/.cache/wal/colors.sh"
fg=$color7
bg=$color2
...
The catch is that this obviously won't work if wal's cache doesn't exist. But then one just need to reset the wallpaper with pywal to get the cache rebuilt.... | How to get background and foreground color values from xrdb in shell script? |
1,528,387,444,000 |
is there way how can I from my personal computer try connection between two servers?
Me from PC want to try connection Server1 -> Server2
|
You could use ping(1) (uses ICMP ECHO REQUEST/REPLY). If you suspect some sort of firewall might interfere, traceroute(8) will show the path followed to the destination (tcptraceroute(8) is a handy wrapper here). You can specify what protocol and port to use, and a slew of exotic options.
| Test connection between two servers [closed] |
1,528,387,444,000 |
Nee to find command to generate output exactly as if ls -p would generate?
With find /path/to/ -mindepth 1 -maxdepth 1 -exec basename {} \; the directories don't have trailing slash.. i need the output folder names to have trailing slash
sample output:
folder 1/
my-file-1.sh
find command to list directory contents ... |
$ find /path/to -mindepth 1 -maxdepth 1 -exec sh -c '
[ -d "$1" ] && printf "%s/\n" "${1##*/}" || printf "%s\n" "${1##*/}" ' _ {} \;
aDirectory/
afile
Explanations:
[ -d "$1" ], this checks if its a directory, if yes then run followed printf:
printf "%s/\n" "${1##*/}"
else, run below printf:
printf "%s\n" "${1... | find command equivalent to ls -p |
1,528,387,444,000 |
I've been using cmake and creating a build folder for my cmake code and I want to easily cd to the build directory. I've been naming my build directory in this format:
/parent/codeandsuch
/parent/codeandsuch_build
I've tried the following alias in my bashrc but its not working. Ive copied the name of the current dire... |
You can't concatenate strings with + in bash. Also you need to prepend a $ to the variable name to use its value. So, instead of:
DIR = DIR + "_build"
use:
DIR="${DIR}_build"
The whole thing becomes:
alias cdbuild='DIR=${PWD##*/} || DIR="${DIR}_build || echo "$DIR" || cd "../$DIR"'
Alternatively:
alias cdbuild='cd ... | Alias CD to a directory that's name is included in current directory |
1,528,387,444,000 |
A little background:
I am running Windows 10, have installed git bash, and created the .bashrc file.
Right now in my .bashrc, I have the following line:
PS1='\w\> '
So suppose I am on my desktop, and there is a folder called test. In git bash, it would show this:
~/Desktop/Test\> (enter command here)
In my cmd, it wou... |
That seems not possible with \w or \W but you can do this:
PS1='$PWD> '
| Change PS1 in .bashrc so that the following directory path is shown: |
1,528,387,444,000 |
I am working on an assignment that requires me to accept user input to search for current users on the server and if the user input is online, I need to output the users name. If the user is not logged in I need to respond accordingly. I have been working on this code for days and can't seem to figure it out. I can se... |
You're close, but the main problem is the bash [[ ]] construct can't have spaces in between the brackets. It think's you're trying to do multiple [ commands, which is the POSIX test command. If you fix that it works, but if the user has multiple ttys open is will print their name once for every one. If you want to ... | Bash User Input Search For Who is On Server If Statement Error Too Many Arguments |
1,528,387,444,000 |
My global preferences, alias cp='cp -iv', is ignored by sudo while using zsh.
I'm setting up a new system, and I'm trying out zsh for my user account. The root user still has bash. In /etc I have:
/etc/bash.bashrc
/etc/zsh/zshenv
Both of these have the above alias, alias cp='cp -iv'.
In the user's directories, neit... |
Workaround for sudo to work with your aliases, e.g. sudo cp ...
alias sudo='sudo '
| Why would `sudo cp src dst` ignore no clobber rule in /etc? [duplicate] |
1,528,387,444,000 |
I've downloaded some files. I want to find out whether these file names are present in file.txt one by one. I've tried following command but not successful. I want to find out using xargs.
ls | xargs grep file.txt
How do I do that?
|
Though I'm not sure what exactly means your "one by one" but here is
Short ls + grep approach:
ls -1 | grep -wf - file.txt
-1 - ls option, lists one file per line
-f file - grep option, obtains patterns from file(or STDIN in case of passing - argument), one per line
The same could be written as:
grep -wf <(ls -1)... | Searching all downloaded files in a file list |
1,528,387,444,000 |
Is there an option in SoX effects processing to mix the wet and dry signals instead of only outputting the wet?
For example, say my effects chain is overdrive into pitch shift:
sox in.wav out.wav overdrive 0.5 gain -0.5 pitch 700
Except I don't want the final file to be just the shifted signal. I want a mix of the dis... |
If I understand you, there is an option especially to mix two signals: -m.
sox in.wav out.wav mix.wav -m
play mix.wav
You can probably do the effect and mix in one command, but I'm just a beginner with sox.
You can pipe the output of sox into another sox using the |command input
filename syntax, and adding -p to mak... | SoX - Mix original signal with effected signal |
1,528,387,444,000 |
How can I have surfraw use google as a default search engine?
Or how could I shorten surfraw google foo to surfraw g foo?
|
Set SURFRAW_customsearch_provider=google.
Then use: sr S foo
If setting via a shell variable, make sure to export it.
| Use google by default in surfraw |
1,528,387,444,000 |
EM7455 connect on Single Board Computer(NanoPC-T2) through USB.
I have attached AndroidRIL_5.1.11 binary files in my android and kernel source after build it and run on my android device.Below error messages received on android Log:
# dmesg | grep sierra
<6>[ 1.184000] usb... |
Not positive but this may be a bug that was fixed with a patch that was added to the Linux Kernel.
Also make sure you have the Sierra Wireless Serial USB, Sierra Wireless WWAN, and Qualcomm QMI drivers built into your kernel.
| Sierra Wireless GSM modem EM7455 + Android Integration Error |
1,528,387,444,000 |
I installed powerline by this way:
pip install --user powerline-status
pip install --user git+git://github.com/powerline/powerline
After that I uninstalled it, but I get this error every time I open a terminal:
/Library/Python/2.7/lib/python/site-packages/powerline/bindings/bash/powerline.sh: No such file or director... |
As nikolas was saying, this is very likely your ~/.profile or your ~/.bashrc files which are calling for powerline.sh.
Try to do the following:
Locate where powerline.sh is called:
#> grep "powerline.sh" .bash* .profile
.bashrc:POWERLINE_BASH=/usr/share/powerline/bindings/bash/powerline.sh
.bashrc: powerline-daem... | powerline error in command line |
1,494,543,840,000 |
I have a long report in the form of text tab-delimnated ( meaning if I open this text file in excel spreadsheet then every word and number will fit in a cell). In this report there are key words that I am looking for and I want to print the
four numbers next to this key word. For example, let's say this paragraph is ... |
grep -Eo 'number( [0-9]+)+' input
| Search for word and the next few words |
1,494,543,840,000 |
I have a command like this:
if [ $battery_level -le 6 -a $STATUS = $NOT_CHARGING ] #Battery Low 1
then
/usr/bin/notify-send -i "$ICONL" "Battery critically low!" "Battery level is ${battery_level}%!"
paplay /usr/share/sounds/freedesktop/stereo/dialog-information.oga
It gives a message and a sound at a certain... |
Just use a while loop:
while [ "$battery_level" -le 6 ] && [ "$STATUS" = "$NOT_CHARGING" ]
| Repeat command after a period of time |
1,494,543,840,000 |
I want a put a text file in a encrypted zip archive. I would currently use:
echo "<my text>" > file.txt
zip --encrypt myarchive.zip file.txt
Is there a way to do the same thing in one single command without having to save a file?
|
zip --encrypt myarchive.zip -j -FI <(echo message)
| How to add a text file to a zip in one single command? [duplicate] |
1,494,543,840,000 |
In command paste - - - -, numbers of - is equal the future column number. In my case, I have 55,000 future column, for me wont need to put 55,000 - what I will can use?
Example:
title1:A1
title2:A2
title3:A3
title4:A4
title5:A5
title1:B1
title2:B2
title3:B3
title4:B4
title5:B5
title1:C1
title2:C2
title3:C3
title4:C... |
String multiplication trick based on this answer: https://stackoverflow.com/a/5349772/4082052
Use substitution to insert programmable number of dashes
paste $(for i in {1..400}; do echo -n '- '; done)
or
paste $(printf -- "- %.s" {1..400})
To know why printf -- was used: Dashes in printf
| Command "paste - - - - ", how to specify a big column number |
1,494,543,840,000 |
What is the cleanest way to require the user to enter password in order to run a particular program without the use of third-party applications? For example, if I type firefox to launch it from the terminal, it will prompt for a password and only run it if the correct password is entered. Something akin to that affect... |
create exampleuser , and set password to it
then change firefox permissions to 700 and change firefore own to exampleruser ; after this you can run firefox only root or exampleuser with sudo or su command.
for exmaple:
sudo useradd exampleuser
sudo passwd exampleuser
sudo chown exampleuser:exampleuser ../firefox
sud... | Cleanest way to require the user to enter password to run a program? |
1,494,543,840,000 |
I am trying to extract the compilation date from a linux command (or cpp would be fine too). I am using:
stat -c %z ./myProgram.bin
However, if I copy myProgram.bin to an another place via ssh for example, the stat command is basically giving me the date of the copy.
How can I get the real compilation date?
Thanks.
|
Thomas Dickey's answer addresses the issue in general, for any (ELF) binary. Given the way your question's phrased, you might find the __DATE__ and __TIME__ predefined macros useful; they allow the compilation date and time to be referred to within a program (so a program knows its own compilation date and time).
Here... | Get compilate date [duplicate] |
1,494,543,840,000 |
I have a service in '/etc/init.d'. In that service, I run a command on a remote machine using ssh as a user. Currently I do this in the following way:
sudo -u user bash -c "ssh [email protected] 'source ~/.envrc ; (cd /catalog; ./bin/catalog start &)'"
This is the start command of that service and the service name is... |
So I fixed it by using nohup command:
sudo -iu user ssh [email protected] "nohup bash -c 'source ~/.envrc ; (cd /catalog; ./bin/catalog start &)'"
| How to run a command on remote host from a service? |
1,494,543,840,000 |
I have the following folder structure:
/backup
/backup/copy.sh
/backup/archive/
/backup/20160405_logs/
/backup/20160405_logs/sql.log
/backup/20160405_logs/bak.log
I want to move the folder 20160405_logs into /backup/archive/. If I run mv /backup/20160405_logs /backup/archive from the CLI (manually type and run) it wo... |
Jeff Schallers' second comment pointed me in the right direction.
My backup script looks like this:
tar source_folder dest_file >> /backup/20160405_logs/bak.log
mv /backup/20160405_logs /backup/archive
echo "Backup complete" >> /backup/20160405_logs /backup/archive
The missing files that are being reported are log fil... | mv misbehaves in shell script [closed] |
1,494,543,840,000 |
I have a command, but I want to get the results into a .txt file I can open. How do I alter my command to allow the results to be put into a text file. I plan to transfer this .txt file to my local desktop.
my command | grep stackoverflow
I have tried: echo my command | grep stackoverflow > ex.txt
Although nothin... |
Well, basically use output-redirection
my command|grep stackoverflow > file #writes output to <file>
my command|grep stackoverflow >> file #appends <file> with output
my command|grep stackoverflow|tee file #writes output to <file> and still prints to stdout
my command|grep stackoverflow|tee -a file #ap... | Unix, create file based on command [duplicate] |
1,494,543,840,000 |
I tried this:
ifconfig br0 192.168.0.1 broadcast 192.168.0.255 netmask 255.255.255.0 network 192.168.0.0 gateway 192.168.0.1 up
But it did not work I am trying to use all of these parameters:
address 192.168.0.1
broadcast 192.168.0.255
netmask 255.255.255.0
network 192.168.0.0
gateway 192.168.0.1
How Would I achieve... |
I found my own result:
ifconfig br0 192.168.0.1 broadcast 192.168.0.255 netmask 255.255.255.0 up
route add default gw 192.168.0.1
| how would I convert this interface block into a command |
1,494,543,840,000 |
I am writing a simple unix script to automate reading of a log file.
The following does not give any output to the terminal. It just asks for the password for buser and then it just hangs. I understand that this is because the commands in -c of su are executed in the background. But the logfile had some logs and i wa... |
This is becoming a very common issue in these days, try it in this way:
ssh -t [email protected] ssh -t aserver 'su - buser -c \"tail -f /logfile\"'
| command line in su - and background |
1,494,543,840,000 |
I'm pretty new - came across this problem. My webserver terminal is looking weird, there are some code echoes and then rows and rows of tilde. Where I type would be at the green square, but nothing I type commands or otherwise do anything. Pressing enter jumps down the square and clears a tilde but does not make any... |
You seem to be in Vi Editor editing mode (look down below the screen: -- INSERT --, is for insert mode).
To change editing mode, you need to press ESC key first. And then to quit/exit vi altogether without saving you can type :q! and press ENTER.
Vi is a widely used command line text file editor comes with almost ever... | Linux server terminal - rows of tildes, can't write commands? |
1,494,543,840,000 |
I have a triple boot of Ubuntu, Haze OS, and Kali Linux, and I would like to run an app installed on another operating system from my Primary OS. Like running chrome installed in Ubuntu while using Haze OS.
Is this possible? And how can I do this if it is?
|
It's rather simple to do something like this using the chroot tool. If you mount say Ubuntu to some location, then you can run the programs from that OS. The process would look something like this.
mount /dev/sdu1 /mnt/otheros #Mount the / of the foreign OS to some directory
chroot /mnt/otheros #You should now be able... | Share apps across multiple Linux distributions? |
1,494,543,840,000 |
using the mpc search command I can find a the filename of a song like so:
mpc search title 'Two Weeks'
The output would look like this: Grizzly Bear - Two Weeks.mp3
Since I also know the location of the mp3 (MPD Music directory), I know how I could delete the file with another command. But I want to have a one-line ... |
On the assumption that only one filename comes back, you can use something like:
rm "/path/to/MPD/Music/directory/$(mpc search title 'Two Weeks')"
If there are multiple results, this will break.
| Delete file returned by "mpc search" with single command |
1,494,543,840,000 |
FileA.txt:
ATGCATGC
GGGGGGTT
TTTTT
AAAA
FileB.txt:
asdfasdf
blah2
ATGCATGC
blah3
blah4
delte-me-too
GGGGGGTT
blah5
blah5
....
I want to compare the each line from FileA.txt and check if it is in FileB.txt. If it is in FileB, I want to delete the following:
Matched Line
One line above
Two lines below
and outp... |
Note: No error checking. Also, assumption is that the input in 2nd file follows the pattern mentioned exactly.
awk 'NR== FNR {a[$0] = $0 ; next } {if (!($0 in a)) {b[count++] = $0; } else {count--; if (count > 0) delete b[count];getline;getline; }} END {for (i=0; i<count; i++) print b[i] }' 1 2
inputs are in 1 and 2... | How to loop through a file and make each line a new regular expression into an awk statement? |
1,494,543,840,000 |
I want to filter grep results by using grep -v option.
But the output does not differ when using a particular pattern.
contents of log.log:
ERROR
error
EXCEPTION
exception
<STATUS>ERROR</STATUS>
<MessageType>ERROR</MessageType>
When I run the command:
egrep -wi 'error|exception' /temp/log.log | grep -v 'error'
give... |
The problem occurs due to the egrep -w 'error|exception'. This command adds special characters before and after the pattern (ie. error or exception) for highlighting these patterns in the grep result.
It is as Harald mentioned. The 'ERROR' pattern did not match grep output statement as the 'ERROR' between the STATUS t... | Grep -v filter not working [closed] |
1,494,543,840,000 |
Merge Two files depending on a column, nth occurrence of a string in column1 of file1 should be merged with nth occurrence of the same string in column1 of file2. I tried join but the results are not as expected.
join <(sort file1) <(sort file2)| column -t | tac | sort | uniq > file3
file1
CAAX-MC oracle.log.Applicat... |
Use awk:
awk 'FNR==NR{a[NR-1]=$0}
FNR!=NR{for(i in a){split(a[i],x," ");
if(x[1]==$1){$0=$0" "x[2];delete a[i];break}}print;}' file2 file1
Notice the argument order: file2 is before file1.
FNR==NR: applies only to the first file (in the arguments list): file2.
a[NR-1]=$0: fills an array a with the lines of ... | Merge Two files depending on a Column, nth occurrence of a string in the column of file 1 to be merged with nth occurrence |
1,494,543,840,000 |
I am using a Raspberry Pi 2 running raspbian.
This little guy is going to basically be a media server.
I would like to be able to push messages when I ssh into the thing, but when I try to echo "message" |write, it doesn't show up on startx.
Is there away to create a popup that will flash in the corner on the televisi... |
Plenty of ways. Like this simple one:
echo "message" | DISPLAY=:0.0 xmessage -geometry -0+0 -timeout 5 -file -
Any solution requires you have access to the X server, though. So perhaps switch to the user owning the display first?
| pushing messages as root to user using startx |
1,494,543,840,000 |
I am wondering if there is way to get the state of the CD drive in the command line if there is an audio cd inserted. Can you play a track on the CD and then get back somehow from the system the 'playing' status? Is there any record of the state of the audio cd in the system? (playing/stopped/idle/paused/etc)
|
Today, nobody tells the CD-Rom to play a CD but rather to read a CD and to send the read data to the audio interface of the computer.
When a CD is actually read, you cannot send/execute another SCSI command to the same drive, so there is no way to tell what you like.
What you can to is to call cdrecord -minfo to get t... | Is there a way to get the status of the audio CD (idle/playing)? |
1,494,543,840,000 |
I have thousands of image files that have a 10-digit number appended to the beginning of the filenames. Immediately following each string of 10 numbers is an underscore. They look like this:
1318487644_IMG_2158.jpg
I need to remove the 10dig number and the underscore, without disturbing what follows, the result of wh... |
Parsing ls output is considered bad practise by some. So it could look something like this (assuming posix shell):
for file in /path/to/file/*
do
part_to_remove=$(echo "$file" | grep -Eo '[[:digit:]]{10}_')
if ! [ -z $part_to_remove ]; then
new_file="${file#$part_to_remove}"
mv "$file" "new_fil... | Remove leading 10-digit number from filenames |
1,494,543,840,000 |
So I want to create an alias called changeAllPermisions that accepts one parameter argument in such a way that when changeAllPermissions argument is called , both Group and Other do not have access to read, write or execute argument. If argument is a directory, then the permissions will be changed to argument as well ... |
chmod already has a recursive flag (-R). From the manpage:
-R, --recursive
change files and directories recursively
So, if you wanted a function to do this for you, you could write something like
function myFunc() {
chmod -R go-rwx -- "$1"
}
Or an alias:
alias myAlias='chmod -R go-rwx'
| change permissions to a file and everything inside , recursively |
1,494,543,840,000 |
I have multiple folders named as follow:
Name1
Name2
...
Name9
Name10
Name11
...
I need to rename them using mv command into:
Name01
Name02
...
Name09
Name10
Name11
...
Any ideas?
|
You seem to be actually renaming only 1-9, so that simplifies things tremendously:
for f in `seq 0 9`
do
mv Name${f} Name0${f}
done
If you start moving into triple digits, things get a bit more complicated, but not insurmountably so:
for f in `seq 0 95`
do
g=`printf %03.f $f`
mv Name${f} Name${g}
done
| rename multiple directories by adding one character [duplicate] |
1,494,543,840,000 |
eg:
CREATE VIEW AIPKEYITEM.SEASONGROUPNETSALES (
CALENDARID ,
PRODUCTGROUPID FOR COLUMN PRDGRPID ,
NETSALESDOLLARS FOR COLUMN NETSA00001 ,
NETSALESUNITS FOR COLUMN NETSA00002 )
AS
SELECT
(SELECT MIN(CALENDARID)
FROM AIPKEYITEM.KEYIT00002
WHERE FISCALYEAR = CAL.FISCALYEAR ... |
How about:
cat myscript | sed 's/FOR COLUMN.*$//g' > myscript.filtered
when myscript is the name of the file which is shown above? Is that what you wish to achieve?
| I want to delete from particular words in all the line if that particular word is present |
1,437,621,284,000 |
I want to use command line to show only the port numbers after ":" only
This is what I'm trying to do
sudo netstat -ant |grep LISTEN|grep :|sort -n|cut -c 45-
It shouldn't list any tcp6 info
|
With sed:
sudo netstat -4tln | sed '1d;2d;s/[^:]*:\([0-9]\+\).*/\1/' | sort -n
| how to show port numbers that are listening for the incoming connections under TCPv4? |
1,437,621,284,000 |
I've loaded a custom driver to linux via mknod. However, now any programs I write to use it need to be run using sudo, which is difficult to do when I'm using an IDE. Is there any way to adjust the driver privileges so I can run my program in my IDE?
|
It should work if you change the ownership and permissions of the device node you've created:
chown kalak:kalak node
chmod 600 node
(assuming your username is kalak, your main group is kalak and your device node is called node).
| Linux driver privileges |
1,437,621,284,000 |
I recently learned here how to open a program from the command line.
my question is, how can i make a set of programs open simultaneously with one command entered?
|
You can run a program simply by typing its name (and Enter, of course).
To run a program "in the background", giving you control of your terminal again, you can append &.
So:
gvim /etc/hosts # Runs gvim and waits until it's finished
But:
gvim /etc/hosts & # Runs gvim and returns control to the terminal
Therefore... | how to open sets of programs simultaneously with command line |
1,437,621,284,000 |
screen command is a nice program for us to run process background, but I found Ctrl + a w do not show screen windows list in xshell(Xmanager component) and Ctrl + a k do not kill this screen terminal for me. However Ctrl + a d to dettach session works! So what's wrong with Ctrl +a w to list sessions?
More serious, How... |
If you're getting logged out when you type ^A d I'm guessing you're still holding down the control key when you're pressing d. ^A ^D is bound to "detach" as well as ^A d. For ^A k and ^A w, try letting go of the control key before pressing the k or the w.
| Running background process with screen command in xshell |
1,437,621,284,000 |
I am running Ubuntu 14.04 on my machine. I am feeling lost when I see different command line commands (or what exactly are they called?) like sudo, apt-get, mkdir, -R, -n etc. while installing different software like Node JS, Mongo DB etc.
What are some good resources where I can find what do different Linux/Unix co... |
man pages are your friend. Whenever you see a command you've never used, run man [name of command]
For example, man sudo will tell you:
NAME
sudo, sudoedit - execute a command as another user
and, lower down:
DESCRIPTION
sudo allows a permitted user to execute a command as the superuser or another ... | What are the meanings of different Unix commands? [closed] |
1,437,621,284,000 |
I've tried numerous thing such as uname -a, env, findsmb, amongst other things but that will only give the hostname which is not the server where the files are hosted... I get that there is nfs server somewhere that is sharing the files to the host that I am connected to, but, I am not sure which command to even det... |
To determine where a file is hosted this is what I do:
cd /path/to/folder
df -k .
The host name where the file is sourced from is at the beginning of second line.
| how to find out the name of the server on which the files are hosted on? [closed] |
1,437,621,284,000 |
I need to monitor a windows host using command line in Nagios.
As we can monitor Remote Linux host by NRPE (check_nrpe)using command line as :
/usr/local/nagios/check_nrpe -H localhost -c somecommand -t 30
What is the command in Linux to monitor windows host using check_nt plugin? I can monitor successfully by graph... |
Actually after searching for long I found this solution:
/usr/local/nagios/libexec/check_nt -H <host> -p <port> -v <command> -l <value>
So I have used this in my script as :
/usr/local/nagios/libexec/check_nt -H $myHost -p 12489 -v CPULOAD -l 5,80,90,10,80,90
/usr/local/nagios/libexec/check_nt -H $myHost -p 12489 ... | Nagios : How to monitor windows host from linux "by command line"? |
1,437,621,284,000 |
I succesfully installed Picasa 3.9 under Crunchbang following this webupd8-tutorial. I also installed libwine-cms:i386. Everything works well and Picasa launches after installation.
The problem: once I close it, I cannot get it to relaunch. I tried the following and neiither works:
picasa
Picasa
Picasa39
wine picasa
... |
Ok, this Rosetta-Stone question gave me the clue:
cd ~/.wine/drive_c/Program\ Files/Google/Picasa3
wine Picasa3.exe
| Launch Picasa under CrunchBang Waldorf |
1,437,621,284,000 |
How to start rexecd daemon/server on ubuntu-11.10 ?
If I try to run the command /usr/sbin/in.rexecd then an error appears as rexecd: getpeername: Socket operation on non-socket
rexecd is remote execution server
|
rexecd is supposed to be run by inetd, tcpd or xinetd daemons. You need to check which one is installed or install one. I would recommend xinetd as it allows the more flexible configuration.
| rexecd daemon for Ubuntu |
1,437,621,284,000 |
I want to archive family videos, films, etc. I'm currently using:
mencoder INPUT.avi -o OUTPUT.avi -ovc x264 -x264encopts bitrate=750 pass=1 nr=2000 -oac mp3lame -lameopts cbr:br=128
I want to retain good quality, but obtain the smallest video size. Can I do better than this? (Command-line applications only please.)
|
The trade-off between size and quality is a personal, subjective one. What you are doing there is transcoding an already-lossy-compressed video from one format to another. An analogy would be recording from one VHS tape to another: the source will have some imperfections in it which will be recorded onto the destin... | Video archiving method? |
1,437,621,284,000 |
I just read in a book (from 2000) how a (unix/linux) server would listen on a port waiting for connections associated with a utility.
An example in the book is about the finger utility.
The netstat output on the server is like this:
proto recv-q send-q local address foreign address state user
[..]
tcp 0 ... |
To answer myself; inetd was what I was looking for; launch a program to process the connection, e.g. netstat.
Linux – Create custom inetd service
Thank you for helping me.
| Binding a utility to an ip/port [closed] |
1,437,621,284,000 |
I have following answer for How to remove a single line from history?. When I do following, the line ( echo hello_world) is not saved into history. Please note that I am using zsh shell.
prompt$ echo hello_world
> # ^ extra space
$ history | tail -n1
1280 history | tail -n
$ echo hello_world
hello_world
$ hi... |
The behaviour that you're observing, i.e. that pressing Ctrl+P brings back the previous command even if it starts with a space and HIST_IGNORE_SPACE is set, is documented (my emphasis):
HIST_IGNORE_SPACE (-g)
Remove command lines from the history list when the first
character on the line is a space, or when one of th... | Is it possible to remove previous command from the zsh shell history when it starts with a space? |
1,437,621,284,000 |
I have a command that I run to try and list PID's and their CPU usage. I am using ps -ef.
Is there a (better) way to do this using top? Also, I had a question about my awk statement. My variable $vGRP is a regular expression. How do I test if $2 is in $vGRP? If so, this can cut out one of my grep calls.
I initially wr... |
Reinventing the wheel apparently.
ps -o pid,pcpu -p $(pgrep "$vPNAME")
| Locating a process ID by CPU usage (Ubuntu) using AWK |
1,587,144,341,000 |
I'm trying to mask some sensitive data in a log file.
I first need to filter out specific lines from the file with a matching pattern and then for those specific lines I need to replace any text that is inside double quotes but leave alone any text that is not.
In the file, all lines that matches with the pattern, th... |
awk '/KEYWORD/{
n=split($0,a,"\"")
for(i=2;i<=n;i=i+2){
gsub(/[A-Z]/,"X",a[i])
gsub(/[a-z]/,"x",a[i])
gsub(/[0-9]/,"0",a[i])
}
sep=""
for (i=1;i<=n;i++){
printf "%s%s",sep,a[i]
sep="\""
}
printf "\n"
next
}
1' file
For example, on your updated in... | Replace specific characters inside quotes |
1,587,144,341,000 |
POSIX and GNU have their syntax styles for options.
For all the commands that I have seen, they accept option-like inputs as command line arguments.
Is it uncommon for a program to accept option-like inputs from stdin (and therefore to use getopt to parse option-like stdin inputs) ? Something like:
$ ls -l
-rw-rw-r... |
tl;dr This is very similar to wanting to use ls in scripts (1, 2), quoting only when necessary, or crossing the streams (which is almost literally what this does, by using stdin for two completely orthogonal things). It is a bad idea.
There are several problems with such an approach:
Your tool will have to handle all... | Why is it uncommon for stdin inputs to have option-like inputs, while common for command line arguments? |
1,587,144,341,000 |
I am doing some challenges. This is one them. I am trying to brute-force 4 digit pin with the password to get my desired answer. After connecting to the port It prompts me to enter the password then space then 4 digit pin. I tried to brute-force the pin using the script:
#!/bin/bash
nc localhost 30002
sleep 2
... |
That's because you're not telling your script to write anything to nc's standard input. Your script starts netcat, waits for it to terminate, and then sleeps for two seconds before executing the for loop. You probably want a construct such as:
for i in {0000..9999}; do
: stuff
done | nc localhost 30002
| Brute-force 4 digit pin with pass using shell script |
1,587,144,341,000 |
I'm trying to create an achive:
$ cd /tmp
$ tar -czf test1.tar.gz -C ~/Downloads/dir1 -C ~/Documents/dir2 -C ~/dir3/dir4/dir5
... which is supposed not to preserve the full path of the directories in it, hence -C
Result
tar: Cowardly refusing to create an empty archive
Try 'tar --help' or 'tar --usage' for more infor... |
Your command is conceptually equivalent to this:
tar -czf test1.tar.gz -C ~/Downloads/dir1 "" -C ~/Documents/dir2 "" -C ~/dir3/dir4/dir5 ""
In human terms:
tar -czf test1.tar.gz: "Make a gzipped tar archive named test1.tar.gz to the current working directory, as follows:..."
-C ~/Downloads/dir1 "": "...First, switch... | Creating a tar.gz archive of multiple directories of different locations -- "tar: Cowardly refusing to create an empty archive" |
1,587,144,341,000 |
I want to find all the files that has the words
“Who”, “What”, “Why”, “How”, “When”. All of the words, in any order. Case Insensitive
I tried:
grep -rl --include='*.adoc' "Who" . | xargs grep -l "What" | xargs grep -l "Why" | xargs grep -l "How" | xargs grep -l "When"
It is giving error like:
grep: Walkthrough/datata... |
The problem you are having is that some of your filenames contain spaces. xargs will split that into multiple "filenames".
Add the -0 option to the xargs to make them split on NULs instead of whitespace, and the --null or -Z option to the grep command line to make it use NULs instead of newlines. (but omit the --nul... | Recursively search for txt files that has all the search strings |
1,587,144,341,000 |
I have a bunch of files and I want to rename them using regular expressions. I want to do this in a Linux Command line.
I have the files
report1.txt
report2.txt
report3.txt
How can I rename these so that they state
myreport1.txt
myreport2.txt
myreport3.txt
Please let me know, I've searched the internet and they ha... |
To answer OP's question in comment: "Is there a way to do it without using a for loop?"
I usually use a dedicated utility for this: mmv
mmv 'report?.txt' 'myreport#1.txt'
(there are several other similar tools around, like rename)
| How do I rename these files at once? [duplicate] |
1,587,144,341,000 |
Have following files.
test.tar.gz.part00
test.tar.gz.part01
test.tar.gz.part02
…
test.tar.gz.part99
Need to replace .gz by .lz4… ideally without using dependencies (such as rename) that do not ship with Debian.
Thanks for helping out!
|
You can use rename for that.
rename gz lz4 ./*part*
Without rename:
for file in ./*part*; do mv "$file" "${file//gz/lz4}"; done
| How to rename subset of filename of all files in directory? |
1,587,144,341,000 |
I'm checking if file present with find command like following -
find ${pwd} | grep 'Test.*zip'
This command returns output with relative path like -
./ReleaseKit/Installable/Test-5.2.0.11.zip
Is there a way to get absolute path of found file using find command?
|
The problem with your
find ${pwd} | grep 'Test.*zip'
is that you don't have a variable called pwd. So this is the same as find | grep 'Test.*zip'. You want to give the current directory as the starting point.
Either use $(pwd) or $PWD instead of ${pwd}. $(pwd) runs the pwd program whilst $PWD uses the variable th... | How to get absolute path of found file using 'find' command in Linux? |
1,587,144,341,000 |
I want to join these 2 files : File 1 (1 million lines) and File 2 (10,000 lines) in new File 3 (should be 1 million lines) using an awk command
File 1 :
471808241 29164840 1 10001 156197396
471722917 21067410 1 31001 135961856
471941441 20774160 1 7001 180995072
471568655 29042630 1 15001 157502996
471524711 20... |
I want to join these 2 files
So use the join command after sorting the files into key order: sort -b -k 5 file1 > sorted-file1
sort -b -k 2 file2 > sorted-file2
join -1 5 -2 2 -o 1.1,1.2,1.3,1.4,2.2,2.1 sorted-file1 sorted-file2
Further reading
"Utilities: join". Shell Command Language. Single UNIX Specification.... | Merge files using a common column value [closed] |
1,587,144,341,000 |
I am following a tutorial
yes > /dev/null & top
Output
I do not understand what this line is doing.
Top only
It seems that I have one process less.
Why?
|
The significant part is the first line in the list of processes show by top. When you run
yes > /dev/null & top
you end up with a yes process using all the CPU it can get. The command above is equivalent to
yes > /dev/null &
top
because & not only puts a process in the background, it also acts as a command separator... | Redirecting with yes > /dev/null & top |
1,587,144,341,000 |
The command line utilities in Linux accept for example:
tail file.log -fn0
But the utils in macOS don't, the options must be first arg:
tail -fn0 file.log
Is it possible to change this?
|
But the Zsh in MACOS doesn't accept, the options must be first arg:
This is very likely because macOS is a BSD-derivative which means that the common utilities (like grep, tail...) are the of BSD-variant, and not the GNU versions which are used on Linux
This means that there are some slight (and sometimes huge) vari... | Command line utilities in macOS only accept options at the first args |
1,587,144,341,000 |
I have a centos and an ubuntu VM in my PC, and whenever I run ls command in centos VM it prints out text with light font weight. But in ubuntu, the same command prints out text with bolder font. Why?
|
As others have noted, the colorization is controlled by the --color flag. Many Linux distributions put an alias for ls in ~/.bashrc or another shell startup file, and the alias includes this flag.
The colors themselves are controlled by the $LS_COLORS environment variable. This is usually also set up in one of your sh... | What is the difference between centos ls and ubuntu ls command? |
1,587,144,341,000 |
I used the * command and I seen this error:
bash: boot: command not found
Why did this error occur?
|
The first word that you type on the command line will be interpreted by your shell as the name of a command.
The shell will expand the * filename globbing character to all visible names in the current directory. The names will be sorted in lexicographical order.
You are in a directory in which the name boot is the nam... | Why is the output of the “*” command boot? |
1,587,144,341,000 |
I'm trying to parse the Sublime Text 3 session file: Session.sublime_session. It consist of what look like JSON formatted stuff.
Using:
cat Session.sublime_session | grep -A13 "\"file\":"
I can get easily get a list (repeated for each file) like this:
"file": "/F/myHW/check_usb_switch.sh",
"semi_transient"... |
jq -r '.windows[]|.buffers[]|.file' Session.sublime_session
This would use the JSON parser jq to parse out all the file nodes from each buffer of each window recorded in the Sublime Text 3 sessions file.
To get the file info together with the first integer of the selection bit, you will have to look elsewhere in the ... | How to get just two items of a json like file |
1,587,144,341,000 |
I have the file like this. ex.(test.txt)
$$BATCHCTRL=TEST-012017
$$STATE=CA AZ
$$FROM_DATE=01/10/2017
$$TO_DATE=01/30/2017
All I need to do is replace this $$STATE=CA AZ with first TWO bytes of this value.
i.e(CA).
The output file should be
$$BATCHCTRL=TEST-012017
$$STATE=CA
$$FROM_DATE=01/10/2017
$$TO_DATE=01/30/201... |
I am assuming that these couples of character after STATE are in capital. If not then you should replace [A-Z] [A-Za-z].
You can use this simple command:
sed -Ei 's/^\$\$STATE=([A-Z]{2}) ([A-Z]{2})/\$\$STATE=\1/g' sed_file
It will match with lines starting with $$ like $$STATE=AB CD and will replace them with $$STATE... | Find String and Replace with SUBSTRING |
1,587,144,341,000 |
Say I'll start writing
sudo cp /etc/var/more/evenMORE/fileABC
and as the target of the copying, I'd like to define the same folder, except just a different filename (whether it is a new name like "randomNAME" or an iteration of the file "fileABC-backup01" shall be irrelevant). How can I reuse the input file so that ... |
sudo cp /etc/var/more/evenMORE/file{ABC,DEF} will copy fileABC as fileDEF in the same folder.
In general cp /xyz/{file1,file2} will copy /xyz/file1 as /xyz/file2. Basically, put anything that is common outside the {} and separate the source and destination names with a , in the {}.
| How can I address the path/file I just specified again? [duplicate] |
1,587,144,341,000 |
I have one production server. On that I have 1 directory for particular object, which will keep piling up the files after it gathered from different network nodes. So it have the files in subdirectories from May-2021 . It generally creates hourly subdirectories for a day and pushed the files into those subdirectories.... |
find . -ctime +2 reports the files whose last change status time is 3 days old or older (where the difference between the time find was started and the ctime of the file, rounded down to an integer number of days is strictly greater than 2).
The ctime, which you can print with ls -lc is updated any time anything about... | Strange behavior "find command" while using +mtime , +mmin options |
1,587,144,341,000 |
I have taken a course in that suddenly I saw this, I understood until the pipe but the options used after the pipe for the command cut are bit confusing
|
With -c cut selects only specified characters or ranges of characters separated by comas:
N N'th byte, character or field, counted from 1
N- from N'th byte, character or field, to end of line
N-M from N'th to M'th (included) byte, character or field
-M from first to M'th (included) byte, character o... | ls -l | cut -c1-11,50- Can Someone Explain the 2nd part after the pipe? |
1,587,144,341,000 |
Can someone explain to me why this doesn't partial match macaddress $mac?
#!/bin/sh
mac="f0:79:60:0f:d3:0e"
if [[ "$($mac)" = 'f0:79:60*' ]]
then
echo "true"
else
echo "false"
fi
As a note, I need to call "$($mac)" inside the if statement otherwise it will not substitute the variable.
|
First, $($mac) has to be fixed to $mac, as Jea said before.
Also just use case statement; double brackets is bash (or maybe zsh) (edit: actually available since ksh; bash and zsh adopted it too) specific but shebang just say '/bin/sh', not 'bash'.
Here are two solutions:
Replace 1st line with #!/bin/bash, #!/usr/bin/... | partial match string in /bin/sh |
1,587,144,341,000 |
I computed a clock on a file exerciceIV_2.C with the gedit command of unix,
And, by a night of september, I decided to use sleep 1000 in order to stop the clock.
I wasn't able to use my device for 1000 seconds!
hopefully I called a friend who told me to use CTRL+C.
How should we do in order to still stop the clock wh... |
while syntax is
while ( cond ) expr ;
you cannot add a ! before (
On a side note, this question would have better fit stackoverflow.
| how to still have control with sleep? [closed] |
1,587,144,341,000 |
Is there a way to know the meaning of the output of a command?
Example given: If I type ls -l, I get this ouput:
[root@localhost junk]# ls -l
total 8
-rw-r--r-- 1 root root 1862 2012-08-25 16:20 a
-rw-r--r-- 1 root root 0 2012-08-25 15:41 a.c
-rw-r--r-- 1 root root 1907 2012-08-25 16:18 b
Now I want to know here w... |
You can use info command to know more details about any command in coreutils.
Here is some portion in info ls, explain the -l option:
`-l'
`--format=long'
`--format=verbose'
In addition to the name of each file, print the file type, file
mode bits, number of hard links, owner name, group name, size, and
... | man command: is there a way to know the meaning of the output of a command > |
1,587,144,341,000 |
I want someone from windows to log in into my server using SSH, so he can edit files and install things. Is there a step to step how to do it? I need to:
Create his user account.
Configure it, giving him access to a single folder and nothing else (how?)
Generate a public key for him on Windows (how?)
Add his public ... |
(2) You may configure sshd to chroot() for this user. See man 5 sshd_config, search for ChrootDirectory and ForceCommand.
(3) You must create a key pair. The public key is used on the server, the private key is used by the client. See ssh-keygen. You may need ssh-keygen -e ... for converting the key so that it is usab... | How to enable someone to SSH to my server from Windows? [closed] |
1,587,144,341,000 |
I would like to install the pdf viewer Okular on a SUSE Linux Enterprise Server 11. I am familiar with apt under Ubuntu, but on SUSE, I only found rpm to install .rpm files. I am wondering how Okular (or essentially any other program) can be installed? I know Okular is KDE, but I saw it here so I hope it is possible t... |
In SLES zypper is the equivalent to apt in Debian and yum on RHEL. You can install Okular with the following:
zypper in okular
Another option is to use the YaST interface.
| How to install Okular under SUSE (on a server)? |
1,587,144,341,000 |
What is the syntax to delimit the arguments of a C program.
For example, if I type :
./myprogram 1 2 3 | grep result
The | grep result will be interpreted as arguments (and passed as argv). So how to terminate the arguments after 3 ?
|
I don't think that's true. The shell is the one interpreting the command line arguments and passing them to the corresponding commands as it (the shell) is parsing them.
So your C program, when it finally get's executed will only see the arguments 1, 2, and 3. The pipe and everything after is the responsibility of th... | Delimiters of program arguments? |
1,587,144,341,000 |
run-parts executes all programs and scripts in a directory -- but when do I need it?
What are some common uses for it?
|
If you manage a server farm, or otherwise a number of similar systems, and e.g. have an application that requires a number of environment settings on each system, you could use run-parts to create a drop-in directory to which you could add and remove script snippets as required, so that each file would hold a group of... | What are some common uses for `run-parts`? [closed] |
1,587,144,341,000 |
I've recently upgraded to Fedora 38 and when I try to sudo dnf update, I get the following error:
Problem: package libheif-freeworld-1.15.2-1.fc38.x86_64 requires libheif(x86-64) = 1.15.2, but none of the providers can be installed
- cannot install both libheif-1.16.1-1.fc38.x86_64 and libheif-1.15.2-1.fc38.x86_64
... |
The libheif-freeworld package has simply not yet been pushed to rpmfusion-free-updates repository at the time of writing. It's still in rpmfusion-free-updates-testing and enabling that repository will let dnf resolve the dependencies and complete the transaction:
sudo dnf --enablerepo=rpmfusion-free-updates-testing up... | Problem with sudo dnf update on Fedora 38 (recently upgraded) |
1,587,144,341,000 |
I constantly see IFS="value" command being referred to as a means of changing the IFS (Internal Field Separator) temporarily, only for the duration of the command provided, yet there are many situations where what looks to me to be similar usage fails.
I am sure these are errors on my part, but In trying to figure ou... |
This is documented in the "Environment" section of the bash manual, which says:
The environment for any simple command or function may be augmented temporarily by prefixing it with parameter assignments, as described in Shell Parameters. These assignment statements affect only the environment seen by that command.
T... | `IFS="value" command` is a popular feature of many shells, but official documentation is hard to find. Where is it documented officially? [duplicate] |
1,587,144,341,000 |
I was looking at Most straightforward way of getting a raw, unparsed HTTPS response to make a GET request to a url over HTTPS, and receive the raw, unparsed response.
the following works:
echo 'GET / HTTP/1.1
Host: google.com
' | openssl s_client -quiet -connect google.com:443 2>/dev/null
However, I want to put the ... |
there is a blank like after
There should be two.
$ echo '"'; cat raw.txt; echo '"'
"
GET / HTTP/1.0
Host: google.com
"
$ cat raw.txt | openssl s_client -quiet -connect google.com:443 2>/dev/null
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
... | why does `echo` works but `cat` does not when pipeing to `openssl` |
1,587,144,341,000 |
I am following instructions in a tutorial.
Download the CIFAR-10 dataset and generate TFRecord files using the provided script. The script and associated command below will download the CIFAR-10 dataset and then generate a TFRecord for the training, validation, and evaluation datasets.
The command that I am supposed t... |
The ${PWD} is a variable substitution of the shell and instructs the shell to insert, instead of this string, the value of the "environment variable" PWD which is always the absolute path of the directory you are currently in and therefore contains the same string you get when running
user@host$ pwd
on the command-li... | What is --data-dir=${PWD} in my tutorial instructions? |
1,587,144,341,000 |
In the ~/.bash_profile I have added some echo statement
echo "omg!!"
echo "$(date) welcome to $HOME"
When I run command like sudo su - foo -c 'ls'
Output:
omg!!
Thu Oct 3 13:44:41 IST 2019 welcome to /home/foo
1.sh 2.sh 1.out 2.out
actually I want output as 1.sh 2.sh 1.out 2.out thats it
without changing in bash_... |
Don't start a login shell:
sudo -u foo ls
or, if you have to go via the root account,
sudo su foo -c ls
The .bash_profile file is sourced for login shells, but not for non-login shells.
| do not source bash_profile or do not echo statements |
1,587,144,341,000 |
I have two big files, the first file contain some intervals with 85K rows:
head data.intervals
id id_uniq numberA numberB
1 g1 5 20
1 g2 6 29
1 g3 17 35
1 g4 37 46
1 g5 50 63
1 g6 70 95
1 g7 87 93
2 g8 3 15
2 g9 10 33
2 g10 60 77
2 g11 90 132
the second file contains some... |
You could do this with Perl using the following method:
$ perl -lane '
my($id, $uniq_id, $lower, $upper) = @F;
$h{$id}{$uniq_id}{MIN} = $lower;
$h{$id}{$uniq_id}{MAX} = $upper;
push @{$order{$id}}, $uniq_id;
}{
while(<STDIN>) {
chomp;
my($id, $number) = split;
print join "\t", $id, ... | how to assign values to intervals with overlapping regions? |
1,587,144,341,000 |
I'm trying to download a zip file from : https://download.sysinternals.com/files/ProcessExplorer.zip (no curl and no WGET). I want to do that by netcat i used this command :
echo -e "GET
https://download.sysinternals.com/files/ProcessExplorer.zip HTTP/1.1\r\nHost: download.sysinternals.com\r\n\r\n" | nc download.sysi... |
So, as far as I know, netcat cannot use HTTPS, but in your code you were connecting to port 80, which means HTTP, not HTTPS.
After the GET you should add the relative address, not the full one.
Something like this will work:
echo -e "GET /files/ProcessExplorer.zip HTTP/1.1\r\nHost: download.sysinternals.com\r\n\r\n" |... | Download zip file from remote HTTPS host using netcat |
1,587,144,341,000 |
I am trying to do both integer and string comparison in a statement as follows:
$ TimeHr=$(date +%_H)
$ Time=Night
$ echo TimeHr
1
$ if ((TimeHr>18 || TimeHr<5 )) && [ Time == "Night" ]; then echo "Night Time"; else echo "Day Time"; fi
Day Time
$ if ((TimeHr>18 || TimeHr<5 )) && [[ Time == "Night" ]]; then echo "Nig... |
I would combine the two conditionals into a single one
if [[ ( $TimeHr -gt 18 || $TimeHr -lt 5 ) && $Time == "Night" ]]; then echo "Night Time"; else echo "Day Time"; fi
Night Time
However your original test has a simple error; inside the [ and [[ tests you need to use $variable and not just variable.
So
if ((TimeHr... | Bash Conditional String and Integer together |
1,538,656,457,000 |
I can redirect output to logger like this:
nohup bin/mytask | logger
But the process hangs, and my cursor doesn't return to the terminal after the command is sent. (I would have to return to terminal with ctrl c and I don't want to quit the process.
So I try this command:
nohup bin/mytask & | logger
But I get this err... |
nohup bin/mytask | logger &
& is a command separator, just like ; and |, and you have to background a whole pipeline, not just one command in it.
| Use nohup and return to terminal and pipe to logger |
1,538,656,457,000 |
I have a string that is separated by spaces and I need to get concated the 2nd and 3rd “word”/field making sure that if more than one space separates the words/fields it is handled properly.
The following works fine:
tr -s " " |cut -d ' ' -f2 -f3 | tr " " "-"
I was wondering is there an even more succinct way of ... |
awk will by default use any number of whitespaces as the field separator, so your issue could be solved by the single awk invocation
awk '{ printf("%s-%s\n", $2, $3) }'
with the data passed to the standard input of awk.
Doing the same thing in the shell (which also, by default, will split the input on whitespaces in ... | Concat specific fields separated by space(s) |
1,538,656,457,000 |
I have some output that is formatted like so:
foo: /some/long/path_with_underscores-and-hyphens/andnumbers1.ext exists in filesystem
foo: /another/one.ext exists in filesystem
bar: /another/path/and/file.2 exists in filesystem
I need to remove those files. How can I extract each path and remove the file? I know that ... |
With awk and its system() function.
awk '{ system("echo rm "$2) }' list
Above is correct when you won't have whitespaces in your files name, if you have try below instead.
awk '{gsub(/^.*: | exists in filesystem$/,""); system("echo rm \"" $0"\"")}' list
Note that, none of the above will be able to detect newlines i... | How to use grep and/or awk to select multiple pathnames in file and remove those files? |
1,538,656,457,000 |
cat telephone.txt | cat | cat | sed -e "s/t/T/" | tee cible | wc -l
|
When you have a command like that, try each piece to see what it does.
For example, run each of these to see what they do:
cat telephone.txt
cat telephone.txt | cat
cat telephone.txt | cat | cat
cat telephone.txt | cat | cat | sed -e "s/t/T/"
cat telephone.txt | cat | cat | sed -e "s/t/T/" | tee cible
cat telephone.t... | What does this command do? |
1,538,656,457,000 |
I need to delete folder, subfolders and files if it exists. I am trying to do the following:
if [ ! -d folder ]; then rm -rf folder; fi
However it doen't work. How can I accomplish this?
|
The if [ ! -d folder ] part is wrong. It's false on both empty and non empty directories. The exclamation mark is the logical not operator: you're checking if the directory does not exist before you delete it.
Remove that exclamation mark.
| Delete folder if it exists [closed] |
1,538,656,457,000 |
Just letters are accepted in words, any other characters are delimiters.
I want to exchange the first word with the third word.
sed -E 's/([A-Za-z]+) [^A-Za-z] ([A-Za-z]+) [^A-Za-z] ([A-Za-z]+)/\3 \2 \1/' filename
I wrote this but don't works correctly
Example:
I 4want5to%change
This string I want to change to:
to 4... |
Using character class [[:alpha:]] to match uppercase and lowercase and the negation [^[:alpha:]] to match all others:
sed -r 's/^([^[:alpha:]]*)([[:alpha:]]+)([^[:alpha:]]+[[:alpha:]]+[^[:alpha:]]+)([[:alpha:]]+)([^[:alpha:]]*)/\1\4\3\2\5/' file.txt
Example:
$ sed -r 's/^([^[:alpha:]]*)([[:alpha:]]+)([^[:alpha:]]+[[:... | How to swap two words with sed and with multiple delimiters? |
1,538,656,457,000 |
I was using udisks to unmount and detach USB devices with following commands which work just fine on Ubuntu 10.04:
udisks --unmount /dev/sdb1
udisks --detach /dev/sdb
Because udisks is not available in Ubuntu 14.04, I was trying to use udisksctl. It works for unmount:
udisksctl unmount --block-device /dev/sdb1
But w... |
The problem may be that you are telling the path to the device instead of the path to the block device.
Try the next command:
udiskctl power-off -b /dev/sdb
With -b you are specifying the path to the device.
Source:
https://askubuntu.com/questions/342188/how-to-auto-mount-from-command-line
| Unable to detach a USB device on Ubuntu 14.04 |
1,538,656,457,000 |
Is there on Ubuntu an best way to execute an program than terminal command "./".
I have put PhpStorm into an folder and when I want execute PhpStorm, I must cd bin/ and execute with this command: "./phpstorm.sh". I think that not the official and best way.
|
./ is not a command. It's a directory (current directory). This just means that you run a file ./phpstorm.sh (file named phpstorm.sh that is in the current directory). Every command that you write is first searched in all the directories in $PATH environment variable. This is why, for instance, ls works and you don't ... | Is there on Ubuntu a best way to execute a program than terminal command "./" |
1,538,656,457,000 |
Pipe (|) and redirections (<, <<, >, >>) both using standard streams (stdin, stdout, stderr), but although only pipe can keep sudo privileges, why?
Works:
sudo echo "hello" | tee /root/test
Doesn't work:
sudo echo "hello" > /root/test
|
Pipe (|) and redirections (<, <<, >, >>) both using standard streams (stdin, stdout, stderr), but altough only pipe can keep sudo prividgles, why?
That's simply not true. You must be mixing things up
sudo echo "hello" | tee /root/test
here echo is run as root, but tee is run as your current user, which doesn't seem... | Why pipe keep sudo and redirection not? [duplicate] |
1,538,656,457,000 |
There are a lot of "Linux command-line cheat sheets" on the internet. But often they only list the commands, sometimes sort and describe them.
What I am looking for is something I would call a "task based" cheat sheet, where I can "ctrl+f" for what I want to do and find the corresponding command. Since beforehand I do... |
This is a well-structured pdf with basic tasks on the command line:
Linux command line for you and me
Search term:
linux where to find good command line documentation
Further reading:
A list of sites which provide Unix documentation, for cases where man-pages are unsuitable.
Parser for GitHub Wikis. Those are no... | Task focused command-line cheat sheet for linux |
1,538,656,457,000 |
I'm using NordVPN version 3.12 on an Ubuntu 18.04.6 media server and I've run into many connection issues. The Linux CLI version is very unstable compared to the desktop version, with the VPN getting stuck in a reconnecting loop. When trying to reconnect, it will run a loading animation until I quit the SSH session an... |
I ended up ditching the NordVPN cli client and going with Openpyn. It's an open-source Python script for OpenVPN and some Nord API services. Link to the project: https://github.com/jotyGill/openpyn-nordvpn
Command used: sudo openpyn ca -f -d -r -t 10 --allow [Ports to Allow] --silent --p2p
While not perfect, in the ev... | Issues with NordVPN on Ubuntu 18.04 |
1,538,656,457,000 |
So i'm starting to get addicted to POSIX standards and simplicity yet i hate not having autocomplete using the arrows to go through characters and i want a cool shell prompt.
so is there anyway that i could have something like fish or Zsh or even bash on the front end so i can have autocomplete, a nice and informative... |
I thought I might have misunderstood your question, because what you seem to be asking for is pretty much the way most everyone operates anyway. We use an interactive shell for, well, interaction. But we expect that scripts are often run by a different shell.
This typically "just works", since the vast majority of t... | Having an interactive shell experience but running everything through dash |
1,538,656,457,000 |
Assume I run a custom app on an arbitrary port on a linux box - let's say 7890.
This is a go language web server. Runs an app on top of HTTP. No HTTPS. It runs as a dedicated but "normal" user with no sudo rights. The firewall rule for this port allows "everyone (world)" to access it.
All ssh access is secured and fi... |
Can an attacker ever gain access to the command line via that exposed port?
If there are vulnerabilities in your app, yes.
what are the most important things I need to take care of so that the app can't be exploited to get access to the box?
That's a very difficult question.
Go is a pretty safe language, so osten... | Can an open port be hacked to get access to the command line? |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.