LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-28-2022, 12:33 PM   #271
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053

Quote:
Originally Posted by Debian6to11 View Post
I do not use the commands frequently and I am VERY careful when I mess with any files.
The problem is that they have the same name as the original ones whilst doing something significantly different.
This will cause problems down the line, unless your sudo password timeout is 0.
 
2 members found this post helpful.
Old 03-28-2022, 03:29 PM   #272
josephj
Member
 
Registered: Nov 2007
Location: Northeastern USA
Distribution: kubuntu
Posts: 214

Rep: Reputation: 112Reputation: 112
ondoho - completely agree with your approach, but your alias hides the very useful scp command.

Another reason not to rename/modify existing commands is two-fold. These commands become habit and if you ever use another system you are likely to use them expecting the modified behavior and you may be unpleasantly surprised. This is best illustrated by an alias for rm that adds the -i flag. Typing rm on the other system will just remove the files without the expected prompt.

The other side of this, is that if you ever let someone else use your system, they will see unexpected behavior when they issue modified commands. Even if you don't allow anyone access, if you are asking for help with a problem and show someone else what you did, they will not be aware of the modified behaviors and may misinterpret what you are showing them.
 
3 members found this post helpful.
Old 03-29-2022, 12:00 AM   #273
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Quote:
Originally Posted by josephj View Post
ondoho - completely agree with your approach, but your alias hides the very useful scp command.
I never said that that's my approach!
I just wanted to point out that there might be a better way to do this, with a quick suggestion.
I overlooked that by that scp would be masked. I edited the post in question.
 
Old 03-29-2022, 11:24 AM   #274
rclark
Member
 
Registered: Jul 2008
Location: Montana USA
Distribution: KUbuntu, Fedora (KDE), PI OS
Posts: 476

Rep: Reputation: 178Reputation: 178
Quote:
Most old UNIX hands will likely ctrl-d out rather than closing the terminal window through any other means.
Thanks. I tried that last night and it works great. Never thought to try <ctrl><d> as 'exit' always worked in Windows and Linux. <ctrl><d> doesn't work in Windows... You just get a ^D displayed there at the prompt.

Last edited by rclark; 03-29-2022 at 11:25 AM.
 
Old 03-29-2022, 11:33 AM   #275
boughtonp
Senior Member
 
Registered: Feb 2007
Location: UK
Distribution: Debian
Posts: 3,597

Rep: Reputation: 2545Reputation: 2545Reputation: 2545Reputation: 2545Reputation: 2545Reputation: 2545Reputation: 2545Reputation: 2545Reputation: 2545Reputation: 2545Reputation: 2545
Quote:
Originally Posted by rclark View Post
<ctrl><d> doesn't work in Windows... You just get a ^D displayed there at the prompt.
Ctrl-D works as described in Bash - even on Windows (as provided by MINGW64 / Git for Windows).

If you're using a version of Bash (not cmd.exe or PowerShell) where it doesn't behave as documented, raise it as a bug.


Last edited by boughtonp; 03-29-2022 at 11:36 AM.
 
Old 03-29-2022, 02:05 PM   #276
Cabbie001
Member
 
Registered: Jan 2020
Location: Canada
Distribution: Slackware64 15.0; Devuan Beowulf 3.0 (64bit)
Posts: 169

Rep: Reputation: Disabled
Quote:
Originally Posted by rclark View Post
Thanks. I tried that last night and it works great. Never thought to try <ctrl><d> as 'exit' always worked in Windows and Linux. <ctrl><d> doesn't work in Windows... You just get a ^D displayed there at the prompt.
Doesn't work in Windows... Are we caring about this? lol
 
Old 03-30-2022, 12:00 PM   #277
rclark
Member
 
Registered: Jul 2008
Location: Montana USA
Distribution: KUbuntu, Fedora (KDE), PI OS
Posts: 476

Rep: Reputation: 178Reputation: 178
Quote:
Windoze ... Are we caring about this? lol
Well, no . At work I work in Windows land, at home I am Windows free and only run Linux (do have Win 7 installed in a VM for a special use case). Have been for years. So have a foot in both worlds. The ^D was just an observation . That said, I don't work with 'bash' in Windows. I do use mingw and mingw64 C compilers for one of our SCADA applications.

Last edited by rclark; 03-30-2022 at 12:05 PM.
 
Old 10-13-2022, 01:45 PM   #278
cprasky
LQ Newbie
 
Registered: Dec 2014
Location: Portsmouth, VA
Distribution: Slackware 15.0
Posts: 5

Rep: Reputation: Disabled
View only the hidden files/directories in $HOME

Code:
#!/usr/bin/bash
# vh: two-line script to view only hidden files
# and directories in $HOME

cd $HOME
ls -lhA |awk '{print $9}' |ls -l $(awk '/^\./ {print}') |less
 
Old 10-13-2022, 04:49 PM   #279
metaed
Member
 
Registered: Apr 2022
Location: US
Distribution: Slackware64 15.0
Posts: 360

Rep: Reputation: 169Reputation: 169
Quote:
Originally Posted by cprasky View Post
Code:
ls -lhA |awk '{print $9}' |ls -l $(awk '/^\./ {print}')
You might be looking for:

Code:
ls -lhd .[!.]* ..?*
 
1 members found this post helpful.
Old 10-13-2022, 10:02 PM   #280
cprasky
LQ Newbie
 
Registered: Dec 2014
Location: Portsmouth, VA
Distribution: Slackware 15.0
Posts: 5

Rep: Reputation: Disabled
Quote:
Originally Posted by metaed View Post
You might be looking for:

Code:
ls -lhd .[!.]* ..?*

Well, thank you for that, it is almost what I was looking for. I will probably just pop that as an alias into my .bashrc, without the -d flag and get rid of the script.
 
1 members found this post helpful.
Old 02-14-2023, 06:56 AM   #281
fraxflax
LQ Newbie
 
Registered: Jan 2018
Location: Sweden
Distribution: Debian
Posts: 24

Rep: Reputation: 5
Talking Replacing bash Interactive Login shell with zsh

cat ~root/.bash_login
Code:
test -n "$PS1" -a -x "`which zsh`" && {
    echo Replacing bash Interactive Login shell with zsh
    exec zsh --interactive --login
}
:-D

... I like to have the root user default to bash on my various machines but running interactively (also as root) I, for various reasons ( https://www.linuxquestions.org/quest...ml#post6176723 ), always use zsh ... sure often as simple as

Code:
ssh -t root@host.domain.my zsh -l
but with this "trick" in .bash_login I can just ssh root@host and also works when logging in on the console as root :-)
 
Old 05-04-2023, 09:30 AM   #282
fraxflax
LQ Newbie
 
Registered: Jan 2018
Location: Sweden
Distribution: Debian
Posts: 24

Rep: Reputation: 5
Quote:
Originally Posted by shruggy View Post
True, but read in Zsh has a similar option -k for this. And also option -q that is well-suited for the case described by Cabbie001 in #230.
absolutely, and it's nice ... for '#!/bin/zsh' scripts :-)

I'm not criticizing, all I'm trying to say is that if one uses shell-specific (non-Posix) features, remember to indicate that in you script instead of by default prefixing all shell scripts '#!/bin/sh' (which is not that uncommonly seen in bash-specific scripts)
 
2 members found this post helpful.
Old 01-18-2024, 07:11 AM   #283
felipeabrao
Member
 
Registered: May 2017
Posts: 43

Rep: Reputation: Disabled
The use of "up-arrow" to show previous commands.
 
Old 01-21-2024, 01:01 PM   #284
rnturn
Senior Member
 
Registered: Jan 2003
Location: Illinois (SW Chicago 'burbs)
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,800

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
Quote:
Originally Posted by usernameok View Post
not a trick but usefull for recall complex commands

$ crtl + r

or

$ history | grep
I've used that via an alias (fih = find in history = "history | grep -i") for some time:
Code:
$ fih <somecommand>
 
Old 01-21-2024, 08:27 PM   #285
wmstrome
LQ Newbie
 
Registered: Aug 2007
Posts: 10

Rep: Reputation: 3
Terminal command "sl"

[QUOTE=greencedar;5995646]I enjoy:

[CODE]~$ sl

Well, it is cute, but not of any practical use.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: What is your favorite Linux terminal trick? LXer Syndicated Linux News 0 08-01-2018 12:41 PM
Poll: (Without the poll) - How is Linux used in your workplace? SlowCoder General 13 09-11-2007 11:03 PM
vim :gui trick and undo-trick dazdaz Linux - Software 3 09-10-2007 02:45 PM
Poll: What is your favorite brand of Motherboard? dstrbd1 Linux - Hardware 2 02-16-2006 05:40 PM
Weekly Hardware Poll, Dec 14th: What's your favorite notebook? finegan Linux - Hardware 18 12-03-2004 12:31 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:07 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration