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
635 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
635 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

3 Pages < 1 2 3Top
 

Change to:
| Lo-Fi Version
0.0130sec    0.35    5 queries    GZIP Disabled
Time is now: 29th March 2024 - 12:42 AM