Signup/Sign In

Answers

All questions must be answered. Here are the Answers given by this user in the Forum.

Try this: ls -ltr. It will give you the recent to the end of the list
3 years ago
My 2 cents for the C or C++ solution: maybe not the most effective approach, but on Linux, you can use the ALSA API (built-in audio handling library of Linux) and use some numerical technique (for example, calculating the average sound level each second) to obtain the level of noise.

Then you can check it in an infinite loop, and if it's greater than a preset treshold, you can use the X11 library to turn off the screen for some seconds, or alternatively (less elegant, but it works) invoke the chvt command using system("chvt 3; sleep 15; chvt 7 ");.
3 years ago
From my .tmux.conf:

# Sane scrolling
***
set -g terminal-overrides 'xterm*:smcup@:rmcup@'
***
This enables native xterm scrolling.
3 years ago
Data from stdin with -d @-

Example:
***
echo '{"text": "Hello **world**!"}' | curl -d @- any url
***
Output:
***

Hello world!


***
3 years ago
The best way is to use rsync over SSH
***
rsync -a -essh /source/ user@dest-server:/dest/

rsync -a -essh user@source-server:/source/ /dest/
***
My favorites options are -Pazvessh --delete :

-a : archive mode (include a lot of default common options, including preserving symlinks)
-z : compress
-v : verbose : show files
-P : show progess as files done/remaining files
-e ssh : do rsync in ssh protocol
--delete : delete files in the destination that are not anymore in the source
3 years ago
Open a telnet session to the specific port, for example:
***
# telnet google.com 80
Trying 74.125.226.48...
Connected to google.com.
Escape character is '^]'.

***
To close your session, hit Ctrl+].
3 years ago
In Bash, when you're not concerned with portability to shells that don't support it, you should always use the double-bracket syntax:

Any of the following:
***
if [[ -z $variable ]]
if [[ -z "$variable" ]]
if [[ ! $variable ]]
if [[ ! "$variable" ]]
***
In Bash, using double square brackets, the quotes aren't necessary. You can simplify the test for a variable that does contain a value to:
***
if [[ $variable ]]
***
This syntax is compatible with ksh (at least ksh93, anyway). It does not work in pure POSIX or older Bourne shells such as sh or dash.
3 years ago
use this
***
du | sort -nr | cut -f2- | xargs du -hs
***
3 years ago
PEM is a container file format often used to store cryptographic keys. It’s used for many different things, as it simply defines the structure and encoding type of the file used to store a bit of data.
3 years ago
Here's the best way to install a .deb file on Ubuntu on the command-line:
***
sudo gdebi skype.deb
***
If you don't have gdebi installed already, install it using sudo apt install gdebi-core.
3 years ago
In case if you need an alternate approach.
***
Install sshfs. if you use ubuntu/debian:

sudo apt-get install sshfs
***
or, if you use centos/rhel:
***
sudo yum install fuse-sshfs
***
or, in macOS
***
brew install sshfs
***
Create an empty dir
***
mkdir /home/user/testdir
***
"link" or "mount" the two directories
***
sshfs user@server.com:/remote/dir /home/user/testdir
***
"unlink" the dirs
***
fusermount -u /home/user/testdir
***
On BSD and macOS, to unmount the filesystem:
***
umount mountpoint
***
or
***
diskutil unmount mountpoint
***
3 years ago
Linux determines the executable search path with the $PATH environment variable. To add directory /data/myscripts to the beginning of the $PATH environment variable, use the following:
***
PATH=/data/myscripts:$PATH
***
To add that directory to the end of the path, use the following command:
***
PATH=$PATH:/data/myscripts
***
3 years ago