New answers tagged command-line
0
votes
Open Microsoft Edge in Ubuntu
Assuming that you install the .deb package from https://www.microsoft.com/en-us/edge, you can use the following command the start MS Edge directly and load the page you want:
$ /opt/microsoft/msedge/...
0
votes
Accepted
caret character unexpected behaviour in regular expressions with grep
My intention is to find the keywords starting with "zip"
The caret ^ matches the beginning of a line and not the beginning of a word ... Therefore, grep '^zip' dirlist*.txt will only match ...
1
vote
Accepted
changing grep command --color from red to another color
The simple solution:
Add --color=always to the grep options... then pipe the result into
| sed -re 's/31m/32m/' and you will get green text instead of the red.
Another way is described in the man page:...
0
votes
RPM Euro Games keyboard backlight not working in ubuntu 20.04
Hey if you are still facing the issue try running the below command in you terminal, it worked for me.
sudo xmodmap -e 'add mod3 = Scroll_Lock
0
votes
Open Microsoft Edge in Ubuntu
The Edge browser from windows is not the one you use in Ubuntu. Download the DEB, install it through software center and it will be available as a suggested browser.
0
votes
How to write a bash script from two commands (Find and replace a text string in all files recursively in current directory)
This site is not a script-writing site, but help to anyone on planet Earth is a strong motive in this community (no discrimination against beings from other planets :-) thogh).
That said, take the ...
0
votes
Accepted
Intermittent lag in command terminal?
welcome to the forum.
System Resources
This seems like a hunt to find which system resource is insufficient but we can't tell because there is not enough information. You could provide details like:
...
2
votes
Accepted
I followed a solution procedure on AskUbuntu, logged out and now all my data is gone (no guest account)
Problem
User home directory and everything in it were deleted
Explanation:
The command rm -rf ~ performs the following actions:
rm: This is the command used to remove files or directories in Unix-...
2
votes
Accepted
What are zsh equivalent to bash's shopt -s globstar and shopt -s dotglob?
Recursive globbing is the default in zsh, it doesn't need to be enabled. The ** glob is simply syntactic sugar here:
A pathname component of the form ‘(foo/)#’ matches a path consisting
of zero or ...
1
vote
Copy a folder name into the name of its files
In a Bash shell loop with mv:
for f in */*; do
if [ "${f%/*}" != "Pictures" ]; then
echo mv -nv -- "$f" "Pictures/${f%/*}${f#*/}"
fi
done
You'll ...
0
votes
Accepted
Invoke a program as a command on any working directory on ubuntu's terminal
Copy your program into your $HOME/bin directory. Next login your $PATH should contain your bin dir, so the program should work as you described.
3
votes
Copy a folder name into the name of its files
If both directories are located in the same parent directory, in Desktop as an example, you can use something like:
cd ~/Desktop
rename -n 's,^(.*)/,Pictures/$1-,' Mexico/*.jpg Spain/*.jpg
Note that ...
0
votes
Copy a folder name into the name of its files
The following script should work.
for file in $(find "./$1" -type f);
do
cp $file "./Pictures/$1$(basename $file)"
done
It goes through the files in the $1 (argument 1) ...
1
vote
Changing Linux file names to NTFS-compatible file names
With Perl's rename:
rename -n 'y/\\: /__\-/ if -f' *
... where -n is for a dry-run (to actually rename files, remove it or change it to -v for verbosity), y will translate each character in the ...
0
votes
Changing Linux file names to NTFS-compatible file names
Create a script, e.g. translate.sh:
#! /bin/bash
old=$1
new=${1//:/_} # Replace colons by underscores.
new=${new// /-} # Replace spaces by dashes.
new=${new//\\/_} # Replace backslashes by ...
0
votes
Switching Plasma theme from the command line
kwriteconfig5 seems to be an actual answer. But there is no documentation on the Internet.
For example, to switch to the default Breeze theme the command is:
kwriteconfig5 --file kdeglobals --group ...
2
votes
How to stop wget command?
Kill the wget command by using pkill, and sending the TERM signal (default for the command):
pkill -x wget
If this doesn't work, send the KILL signal instead:
pkill -9 -x wget
0
votes
How to exit gpick color picker after picking from a keyboard shortcut?
To pick single color and output use:
gpick --pick --single --output
or:
gpick -pso
0
votes
Accepted
Database not saving imported sql file in terminal MySQL
It turns out the sql file that I imported had a USE query.
I was just supposed to use the database that were set in the sql file, or delete the USE query in said sql file.
Thank you @glenn jackmann ...
0
votes
How do I select a field/column from the output of `ls -l`?
I need to catalog my installed applications prior to backing up and upgrading and encountered this issue trying to figure out how to trim ls output, but the awk applications suggested in other Ask ...
0
votes
Home directory not being created
My issue was that SELinux was preventing creation of home directory upon login by an unprivileged user:
$ ls -ldZ /home/
drwxr-xr-x. root root system_u:object_r:root_t:s0 /home/
That root_t was ...
3
votes
How to fix "chmod" permissions after running "chmod 222 /bin/chmod"?
You can execute a file that lacks execute permission simply by calling its interpreter. Here's a very simple example:
$ touch file
$ stat -c '%a' file
664
$ echo 'echo hello' > file
$ ./file
bash: ....
4
votes
Cut folder names out of string
Oh okay, here is a sed answer
$ echo 'TRUE|/home/linux/test|(null)|' | sed -r 's#.*/([^|]+)\|.*#\1#'
test
Explanation:
-r use extended regex
s#...#..# find and replace using # as an alternative ...
0
votes
Not able to update or upgrade after upgrading from Python 3.10.12 to Python 3.11
You can try using re-installing the gnome-terminal.
First, you'd like to take a back of the gnome setting if you configured it well. Here - https://askubuntu.com/a/1056392/1774643
Second, re-install ...
3
votes
Cut folder names out of string
It's not really clear from your question if you want to get the third item of an absolute path or if you want to get the last item of an absolute path.
If you want to get the third item of an ...
10
votes
Cut folder names out of string
There are already two working solutions here, but I just wanted to also point out the following method, which maybe maps onto the imperative mindset more.
echo 'TRUE|/home/linux/test|(null)|' | awk -F ...
13
votes
Cut folder names out of string
Bash has a very easy way to match elements of a path (as long as your path is defined as a variable) with parameter expansion.
Using the ${parameter##word} construct, you search from the beginning of ...
0
votes
accidentally moved almost all my files in a new directory, is it the end for me?
The mv command doesn't keep a record of file movements, and the metadata of the moved files will not contain a history of last locations.
I think your best option now will be to write some scripts to ...
8
votes
Accepted
Cut folder names out of string
If you would like to get "Extra credit" for your assignment, Then use awk
echo 'TRUE|/home/linux/test|(null)|' | awk -F '[|/]' '{print $5}'
The awk option -F defines the field separator(s). ...
0
votes
Login for Terminal
On my side, it's revesed. Ctrl + Alt + F1 turns me back to graphical session. Ctrl + Alt + F3 takes me to the terminal session.
0
votes
How do I determine the total size of a directory (folder) from the command line?
One can use 7z (sudo apt-get install p7zip-full) to determine the total apparent size of a directory from the command line. Example:
7z -mx=0 a temp16584.zip /path/to/directory
It will show the total ...
2
votes
How to fix unresponsive Terminal
‘.bashrc’ is executed when you start a Terminal session so, yes, that is a probable cause. You’ve likely added something in there which is not finishing and the Terminal session is waiting for it to ...
0
votes
How do I rerun the second-to-last command?
On top of using Ctrl-R <term> or !-2 to re-run an old command, you can also view your command history and run it by index as well. Say your history looks like:
...
1770 ls
1771 ...
0
votes
How do I open Ubuntu Software Center via Terminal?
For Ubuntu 22.04.3 use the command
snap-store
In case it does not load try this:
killall snap-store
sudo snap refresh
source: Ubuntu software does not load in Ubuntu 22.04.3 LTS
1
vote
Bash script using eyeD3 to remove extra tags from mp3 files
The error is from mawk, which is the default implementation of awk in Ubuntu. Sometime between Ubuntu 18.04 and Ubuntu 20.04, this was fixed so that mawk would work fine with the FS as give ():):
% ...
0
votes
Arrow keys, Home, End, tab-complete keys not working in shell
I believe it depends on the terminal and the environment the terminal operates in. There are various issue sources which may affect the case.
However, in Konsole terminal connected through SSH to a ...
0
votes
How to completely restart script from inside the script itself
Late & noob, but I had to use absolute path to make mine work:
exec "/usr/local/bin/audio-device-switch.sh"
(exec "$ScriptLoc" didn't work for me)
0
votes
Accepted
Custom alias to run and compile .c file
I don't think you can include a variable within an alias. And in any case, you cannot use a variable within single quotes, you'd have to use doublequotes instead.
This function should work. Place ...
0
votes
How do I open Ubuntu Software Center via Terminal?
For me following worked:
software-properties-gtk
0
votes
"Set document metadata failed" when I run sudo gedit
enter image description here
In my case, I was able to remove it by putting &>/dev/null on similar warnings.
3
votes
Special characters 158 and 159 stopping my functions in terminal
0x9e (PM) and 0x9f (APC) are C1 controls codes - an 8-bit extension of the ASCII C0 controls. As noted in Control Bytes, Characters, and Sequences, in an ANSI VTxxx compatible terminal they (and a few ...
0
votes
Accepted
fsleyes segmentation fault (core dumped)
The update may have caused the C-based libraries to go out of sync between your system and the FSLeyes compilation. Let's reinstall it the clean way using pip:
Create a new file (and directory if ...
2
votes
How to give permission to my current user
Very good and correct answer by yxz
The only thing that would improve it is an actual example (even though it is implied).
As I may not comment yet (not enough reputation points) I have to write an ...
0
votes
How can I use following password-prompting dialog from shell? (GNOME)
I think that the corrent solution would be to use pinentry-gnome3. IIRC, it is a dependency of gpg
askpass() {
prompt=$1
echo -e "SETPROMPT $prompt\nGETPIN\nBYE" | pinentry-gnome3 | ...
0
votes
Comparing the contents of two directories
A few iteration with ChatGPT.
Copy the code and save as compare-dirs.py.
Usage:
python3 compare-dirs.py dir1 dir2
import os
import sys
# ANSI escape codes for colors
RED = '\033[91m'
YELLOW = '\033[...
1
vote
Backporting: Does anyone have a function to mimic bash 4 associative array?
I wrote the following and it works to simplest of my needs:
#!/bin/bash
declare -a __MIMIC_ASSOC_ARRAY__VARNAME=()
declare -a __MIMIC_ASSOC_ARRAY__VARKEY=()
declare -a __MIMIC_ASSOC_ARRAY__VARVALUE=()...
0
votes
Check what kind of hardware slots are available linux
To find out if I had m.2 slots and if they were available, I used the following command:
sudo dmidecode --type slot
This gave me all the slots I have in the system and their availability.
1
vote
Accepted
Terminal autocompletion not working
I found the solution!
Apparently Coursier (from Scala) was installed on my computer, and it made a file (or whatever it was) always present: .scala-cli.aux, which made it always a candidate for ...
0
votes
Terminal not launching in Ubuntu 22.04
I had the same issue after my auto-update re-installed memory-hog useless Snap again. I've never used evil Snap, and I've purged it from my system many times.
Also the same update made changes in the ...
0
votes
Is there a way to toggle Do Not Disturb from the commandline?
(Your question mentions that you are looking for keyboard shortcut)
The default key combination (as of Ubuntu 22.04) "Super+V" opens the notification drawer, and then pressing space should ...
Top 50 recent answers are included
Related Tags
command-line × 22921bash × 5407
scripts × 2735
gnome-terminal × 868
text-processing × 862
permissions × 713
server × 702
apt × 673
ssh × 565
14.04 × 543
sudo × 511
software-installation × 491
python × 488
files × 485
16.04 × 450
gnome × 442
networking × 428
directory × 417
grep × 366
18.04 × 361
shortcut-keys × 357
12.04 × 355
sed × 351
package-management × 335
find × 327