Welcome Guest ( Log In | Register )

Outline · [ Standard ] · Linear+

 Any interesting commands in Linux?

views
     
TSFlierMate
post Nov 22 2022, 07:38 PM

On my way
****
Validating
543 posts

Joined: Nov 2020
QUOTE(d4n3sh @ Nov 11 2022, 05:26 PM)
CODE
sudo !!
is one I use alot. Every time I go duh! I forgot to sudo.

CODE
❯ whoami
user1
❯ sudo !!
❯ sudo whoami
Password:
root

*
Thanks to danesh, learnt something new:
(double exclamation point) refers to the previous command; the command !! alone on an input line reruns the previous command.
FlierMate4
post Feb 12 2023, 06:30 PM

Getting Started
**
Validating
90 posts

Joined: Jan 2023
@angch taught me this, thank you.

Change custom prompt, PS1.

CODE
export PS1="foo"
(Or anything name you want to display)

user posted image

Optionally, you can add \w for current directory, \h for host name, \u for username, and \$ for dollar sign.

CODE
export PS1="foo \w:\$"

Now looks better right?

user posted image

To decorate it with color (in terminal), use ANSI escape sequence.

This post has been edited by FlierMate4: Feb 18 2023, 11:36 PM
silkworm
post Mar 3 2023, 11:02 PM

Enthusiast
Group Icon
Elite
962 posts

Joined: Jan 2003
From: Kajang


Before ripgrep and ag (the silver searcher), my go-to file search command was find and grep strung together with xargs:

CODE
find . -name '*.java' -print0 | xargs -0 grep 'some-variable-or-function-name'

The find '-print0' and xargs '-0' options go together, according to the man page, but I usually skip it out of laziness tongue.gif

I usually follow up the command with sed like so:
CODE
find . -name '*.java' -print0 | xargs -0 sed -i 's/old-thing/new-thing/g'

Where old-thing is usually the same search string used in the earlier grep.

Handy when you're ssh'ed into some server that you can't simply install packages.
MatQuasar
post Jun 18 2023, 04:24 PM

Getting Started
**
Validating
292 posts

Joined: Jun 2023
Anybody has experience using "strace"? Web search says it dump all system calls used in a program.
I seen someone use
CODE

strace ./yourapp



angch
post Jun 18 2023, 08:54 PM

On my way
****
Junior Member
636 posts

Joined: Jul 2006
QUOTE(MatQuasar @ Jun 18 2023, 04:24 PM)
Anybody has experience using "strace"? Web search says it dump all system calls used in a program.
I seen someone use
CODE

strace ./yourapp

*
Yes? I use it all the time on misbehaving processes. sudo strace -p $pid
angch
post Jul 4 2023, 02:12 PM

On my way
****
Junior Member
636 posts

Joined: Jul 2006
It has been brought to my attention that the existence of aria2c https://aria2.github.io/ is not common knowledge.

tongue.gif

Use it. How else you're gonna maximize your fancy fibre connections?
MatQuasar
post Aug 16 2023, 10:59 PM

Getting Started
**
Validating
292 posts

Joined: Jun 2023
user posted image
MatQuasar
post Dec 17 2023, 02:15 PM

Getting Started
**
Validating
292 posts

Joined: Jun 2023
I am not Linux expert, only learned it since July 2021.... so I am quite new to Linux command like "grep". Just tried it last month.

user posted image

user posted image
Mat Quasar
post Nov 19 2024, 06:25 PM

New Member
*
Validating
26 posts

Joined: Nov 2024
Last week or so, I learnt new command dmesg. Can also use in conjunction with grep to filter the unwanted messages.

QUOTE
dmesg is used to examine or control the kernel ring buffer. The default action is to display all messages from the kernel ring buffer.

Mat Quasar
post Nov 25 2024, 05:27 PM

New Member
*
Validating
26 posts

Joined: Nov 2024
QUOTE(Mat Quasar @ Nov 19 2024, 06:25 PM)
Last week or so, I learnt new command dmesg. Can also use in conjunction with grep to filter the unwanted messages.
*
Example screenshot in Debian 12.8.

I used two lines:
CODE

dmesg | grep "AMD"
dmesg


user posted image
Mat Quasar
post Dec 2 2024, 10:04 PM

New Member
*
Validating
26 posts

Joined: Nov 2024
Nice command to read address of entry point of a ELF32/64 binary executable file:

CODE
readelf -h your_elf_filename | grep "Entry" | awk '{print $4}'


Note the "$4" is the 4th column in the line "Entry point address: 0xXXXXXXXX"

If your Linux distribution doesn't have "readelf", then you can install the "binutils" package.
For example in Debian:
CODE
sudo apt-get install binutils



JLA
post Jan 3 2025, 11:18 AM

Look at all my stars!!
*******
Senior Member
2,539 posts

Joined: May 2008
$ dwebp
CODE
$ for FILE in *.webp; do dwebp "$FILE" -o
"${FILE%.*}.png"; done

convert webp to png





3 Pages < 1 2 3Top
 

Change to:
| Lo-Fi Version
0.0157sec    0.66    5 queries    GZIP Disabled
Time is now: 18th January 2025 - 09:33 PM