ust understand that to reproduce a 20kHz frequency, you need a sample rate of 40kHz.
To have a little bit of room and leeway, we settled on a sample rate of 48kHz (a multiple of 8) for playback, and 96kHz for recording. We record at this frequency only to make sure absolutely no data is lost. You might be more familiar with 44.1kHz for audio, which is a standard we settled on for CD playback and NTSC. A lot of scientific research has been done on sound quality, and there is no evidence to suggest people can tell the difference between 48kHz or anything higher.
**MYTH BUST:** Humans cannot hear beyond 20 kHz, period. Anyone who claims to be able to is either supernatural or lying to you - I'll let you choose which.
What is bit-depth? Or: HOW IT MAKE SOUND REALLY NICE?
-----------------------------------------------------
Remember how I told you to remember that PCM rounds values to the nearest step? This has to do with how binary works. The more bits, the bigger the number you can store. In PCM, the bit-depth decides the number of bits of information in each sample. With 16-bit, the range of values that can be stored is 0 to 65535. Going beyond this is pointless for humans, with no scientific research showing any proven benefit, though marketeers would like you to believe there's benefits.
**MYTH BUST:** 24-bit depth is often touted as 'high-resolution audio', claiming benefits of a better sonic experience. Such is nothing more than marketing speech, there is no meaningful data 24-bit can capture that 16-bit cannot.
Channels? Or: HOW IT CAN MAKE SOUND IN LEFT BUT NOT RIGHT?
----------------------------------------------------------
We'll briefly touch on the last part of PCM audio, channels. This is very self explanatory, humans have two ears and can hear separate sounds on both of them, which means we have stereo hearing. As a result, most music is recorded with 2 channels. For some surround settings, you need more channels, this is why you may have heard of 5.1 or 7.1; the first digit is the amount of channels the PCM carries.
For most desktop usage, the only sound we care about is 2-channel PCM.
Recap
-----
So, we've covered all the elements of PCM sound. Let's go over it quickly: sample rate is expressed in Hz and is how often a sample of a waveform is captured, representing the x-axis of a waveform. Bit-depth is the bits of information stored in each sample, and represents the y-axis of the waveform. Channels decide how many simultaneous outputs the PCM can drive separately, since we have 2 ears, you need at least two channels.
As a result, the standard audio playback for both consumers and professionals is 48kHz, 16-bit, 2 channel PCM. This is more than enough to fully represent the full range of human hearing.
How it works in Linux
=====================
So, now that we know how PCM works, how does Linux make sound? How can you make Linux sound great? A few important components come into play here, and we'll need to discuss each of them in some detail.
ALSA
----
ALSA is the interface to the kernel's sound driver. ALSA can take a PCM signal and send it to your hardware by talking to the driver. Something important to know about most DACs is that they can only take one signal at a time, actually. That means that only a single application can send sound to ALSA at once. Long ago, in a darker time, you couldn't watch a movie while listening to music!
However, one day, someone set out to change this rather awkward situation...
PulseAudio
----------
When you think audio on Linux, PulseAudio is probably among the first things you think of. PulseAudio is NOT a driver, nor does it talk to your drivers. Actually, PulseAudio only does two things that we'll discuss in detail later. PulseAudio talks to ALSA, taking control of its single audio stream, and allows other applications to talk to PulseAudio instead. Pulse is an 'audio multiplexer', turning multiple signals into one through a process that is called **mixing.** Mixing is an incredibly complicated subject that we won't talk about here.
To be able to
To have a little bit of room and leeway, we settled on a sample rate of 48kHz (a multiple of 8) for playback, and 96kHz for recording. We record at this frequency only to make sure absolutely no data is lost. You might be more familiar with 44.1kHz for audio, which is a standard we settled on for CD playback and NTSC. A lot of scientific research has been done on sound quality, and there is no evidence to suggest people can tell the difference between 48kHz or anything higher.
**MYTH BUST:** Humans cannot hear beyond 20 kHz, period. Anyone who claims to be able to is either supernatural or lying to you - I'll let you choose which.
What is bit-depth? Or: HOW IT MAKE SOUND REALLY NICE?
-----------------------------------------------------
Remember how I told you to remember that PCM rounds values to the nearest step? This has to do with how binary works. The more bits, the bigger the number you can store. In PCM, the bit-depth decides the number of bits of information in each sample. With 16-bit, the range of values that can be stored is 0 to 65535. Going beyond this is pointless for humans, with no scientific research showing any proven benefit, though marketeers would like you to believe there's benefits.
**MYTH BUST:** 24-bit depth is often touted as 'high-resolution audio', claiming benefits of a better sonic experience. Such is nothing more than marketing speech, there is no meaningful data 24-bit can capture that 16-bit cannot.
Channels? Or: HOW IT CAN MAKE SOUND IN LEFT BUT NOT RIGHT?
----------------------------------------------------------
We'll briefly touch on the last part of PCM audio, channels. This is very self explanatory, humans have two ears and can hear separate sounds on both of them, which means we have stereo hearing. As a result, most music is recorded with 2 channels. For some surround settings, you need more channels, this is why you may have heard of 5.1 or 7.1; the first digit is the amount of channels the PCM carries.
For most desktop usage, the only sound we care about is 2-channel PCM.
Recap
-----
So, we've covered all the elements of PCM sound. Let's go over it quickly: sample rate is expressed in Hz and is how often a sample of a waveform is captured, representing the x-axis of a waveform. Bit-depth is the bits of information stored in each sample, and represents the y-axis of the waveform. Channels decide how many simultaneous outputs the PCM can drive separately, since we have 2 ears, you need at least two channels.
As a result, the standard audio playback for both consumers and professionals is 48kHz, 16-bit, 2 channel PCM. This is more than enough to fully represent the full range of human hearing.
How it works in Linux
=====================
So, now that we know how PCM works, how does Linux make sound? How can you make Linux sound great? A few important components come into play here, and we'll need to discuss each of them in some detail.
ALSA
----
ALSA is the interface to the kernel's sound driver. ALSA can take a PCM signal and send it to your hardware by talking to the driver. Something important to know about most DACs is that they can only take one signal at a time, actually. That means that only a single application can send sound to ALSA at once. Long ago, in a darker time, you couldn't watch a movie while listening to music!
However, one day, someone set out to change this rather awkward situation...
PulseAudio
----------
When you think audio on Linux, PulseAudio is probably among the first things you think of. PulseAudio is NOT a driver, nor does it talk to your drivers. Actually, PulseAudio only does two things that we'll discuss in detail later. PulseAudio talks to ALSA, taking control of its single audio stream, and allows other applications to talk to PulseAudio instead. Pulse is an 'audio multiplexer', turning multiple signals into one through a process that is called **mixing.** Mixing is an incredibly complicated subject that we won't talk about here.
To be able to
mix sounds, one must make sure that all the PCM sources are in the same format (the one that's being sent to ALSA); if the PCM format being sent to Pulse does not match the PCM format being sent to ALSA, pulse does a step before mixing it called **resampling.** Resampling is another very complicated subject that can turn a 8kHz, 4-bit, 1-channel PCM stream into a 24kHz, 24-bit, 2-channel PCM stream.
These two things allow you to play a game, listen to music and watch YouTube, and notifications to produce a sound all at the same time. PulseAudio is the most critical element of the Linux sound stack.
**FACT:** PulseAudio is a contentious subject, many people have a dislike for this particular bit of software. In all honesty, PulseAudio was brought to the general public in a bit of a premature state, breaking audio for many people. PulseAudio these days is a very stable, solid piece of software. If you have audio issues these days, it's usually a problem in ALSA or your driver.
What is resampling?
-------------------
Resampling is the process of turning a PCM stream into another PCM stream of a different resolution. Your DAC only accepts a limited range of PCM signals, and it is up to the software to make sure the PCM stream is compatible. There is almost no DAC out there that doesn't support 44.1kHz, 16-bit, 2-channel PCM, so this tends to be the default. When you play an audio source (like an OggVorbis file), the PCM stream might be 96kHz, 24-bit, 2-channel PCM.
To fix that, PulseAudio will use a **resampling algorithm**. There are two kinds of resampling methods: upsampling and downsampling. Upsamling is lossless, since you can always represent less data with more data. Downsampling is lossy by definition, you cannot represent 24-bit PCM with 16-bit PCM.
**MYTH: Downsampling is a loss in quality!** This is only true in a technical sense, or if you are downsampling to less than 48kHz, 16-bit PCM. When you downsample a 96kHz, 24-bit PCM stream to a 48kHz, 16-bit stream, no meaningful data is lost in the process; because the discarded data lies outside of the human ear's hearing range.
**FACT: Resampling is expensive.** Good quality resampling algorithms actually take a non-trivial amount of processing power. PulseAudio defaults to a resampling method with a good balance between CPU time used and quality.
What is mixing?
---------------
Mixing is the process of taking two PCM streams and combining them into one. This is extremely complicated and not something we're going to discuss at length. It is not important to understand how this works, only to understand that it exists. Without mixing, you wouldn't be able to hear sounds from multiple sources. This is true not just for PulseAudio and computer sound, this is true for anything. In real life, you might use an A/V receiver to accept sound from your TV and music player at once, the receiver then mixes the signals and plays it through your speakers.
What is encoding?
-----------------
Finally we can talk a little about encoding. Encoding is the process of taking a PCM stream and writing it to a permanent format, two types exist. You have *lossy* encoding and *lossless* encoding. Lossy encoding removes data from the PCM stream to safe space. Usually the discarded data is useless to you, and will not make a difference in sound quality; examples of lossy encoding are *MP3*, *AAC* and *Ogg Vorbis*. *Lossless* encoding takes a PCM stream and encodes it in such a way that no data is lost, examples of lossless encodings are *FLAC*, *ALAC* and *WAV.*
Note that lossy and lossless do not mean compressed and uncompressed. A lossless format can be compressed and usually is, as uncompressed lossless encoding would be very large; it would just be the raw PCM stream. An example of lossless uncompressed audio is *WAV*.
A new element encodings bring is their *bit rate*, not to be confused with samplerate and bit depth. Bit rate has to do with how much data is stored in every second of audio. For a lossless, uncompressed PCM stream this is easy to calculate with the formula `bi
These two things allow you to play a game, listen to music and watch YouTube, and notifications to produce a sound all at the same time. PulseAudio is the most critical element of the Linux sound stack.
**FACT:** PulseAudio is a contentious subject, many people have a dislike for this particular bit of software. In all honesty, PulseAudio was brought to the general public in a bit of a premature state, breaking audio for many people. PulseAudio these days is a very stable, solid piece of software. If you have audio issues these days, it's usually a problem in ALSA or your driver.
What is resampling?
-------------------
Resampling is the process of turning a PCM stream into another PCM stream of a different resolution. Your DAC only accepts a limited range of PCM signals, and it is up to the software to make sure the PCM stream is compatible. There is almost no DAC out there that doesn't support 44.1kHz, 16-bit, 2-channel PCM, so this tends to be the default. When you play an audio source (like an OggVorbis file), the PCM stream might be 96kHz, 24-bit, 2-channel PCM.
To fix that, PulseAudio will use a **resampling algorithm**. There are two kinds of resampling methods: upsampling and downsampling. Upsamling is lossless, since you can always represent less data with more data. Downsampling is lossy by definition, you cannot represent 24-bit PCM with 16-bit PCM.
**MYTH: Downsampling is a loss in quality!** This is only true in a technical sense, or if you are downsampling to less than 48kHz, 16-bit PCM. When you downsample a 96kHz, 24-bit PCM stream to a 48kHz, 16-bit stream, no meaningful data is lost in the process; because the discarded data lies outside of the human ear's hearing range.
**FACT: Resampling is expensive.** Good quality resampling algorithms actually take a non-trivial amount of processing power. PulseAudio defaults to a resampling method with a good balance between CPU time used and quality.
What is mixing?
---------------
Mixing is the process of taking two PCM streams and combining them into one. This is extremely complicated and not something we're going to discuss at length. It is not important to understand how this works, only to understand that it exists. Without mixing, you wouldn't be able to hear sounds from multiple sources. This is true not just for PulseAudio and computer sound, this is true for anything. In real life, you might use an A/V receiver to accept sound from your TV and music player at once, the receiver then mixes the signals and plays it through your speakers.
What is encoding?
-----------------
Finally we can talk a little about encoding. Encoding is the process of taking a PCM stream and writing it to a permanent format, two types exist. You have *lossy* encoding and *lossless* encoding. Lossy encoding removes data from the PCM stream to safe space. Usually the discarded data is useless to you, and will not make a difference in sound quality; examples of lossy encoding are *MP3*, *AAC* and *Ogg Vorbis*. *Lossless* encoding takes a PCM stream and encodes it in such a way that no data is lost, examples of lossless encodings are *FLAC*, *ALAC* and *WAV.*
Note that lossy and lossless do not mean compressed and uncompressed. A lossless format can be compressed and usually is, as uncompressed lossless encoding would be very large; it would just be the raw PCM stream. An example of lossless uncompressed audio is *WAV*.
A new element encodings bring is their *bit rate*, not to be confused with samplerate and bit depth. Bit rate has to do with how much data is stored in every second of audio. For a lossless, uncompressed PCM stream this is easy to calculate with the formula `bi
t rate = sample rate * bit depth * channels`, for 16-bit, 48kHz, 2 channel PCM this is 1,5 Mbit. To get the value in bytes, divide by 8, thus 192kB per second.
The bit rate of an encoder means how much the audio will be compressed. PCM compression is super complicated, but it generally involves discarding silence, cutting off frequencies you cannot hear, and so forth. Radio encoding has a bit rate of roughly 128 Kbps, while most CDs have a bit rate of 170kBps~ (yes, bytes!)
Lastly, there is the concept of VBR and CBR. VBR stands for **V**ariable **B**it **R**ate, which CBR stands for **C**onstant Bit Rate. In a VBR encoding, the encoder aim for a target bit rate that you set, but it can deviate if it thinks it needs more or less. CBR will encode a constant bit rate, and will never deviate.
**MYTH: Lossless sounds better than lossy.** This is blatantly untrue, lossless audio formats were created for perservation and archival reasons. When you encode a lossy file from a lossless source, and you make sure that it's a 48kHz, 16-bit PCM encoding, you will not lose any important information. What is enough depends on the quality of the encoder. For OggVorbis, 192kbps is sufficient, for MP3, 256kbps should be preferred. 320kbps is excessive and the highest quality supported by MP3. In general, 256kbps does the trick, but with storage being abundant these days, you can play it safe and use 320kbps if it makes you feel better.
**MYTH: CBR is better than VBR.** There is no reason not to use VBR at all, there is no point in writing 256Kbps of data if there is only silence or a constant tone. Let your encoder do what it does best!
**FACT: Never encode a lossy format to another format.** You will compress data that is already compressed. This will always result in a further loss of data, even if the target format is a higher bit rate.
TL;DR, I JUST WANT THE BEST SOUND QUALITY
=========================================
Here is a quick guide to achieving great sound quality on Linux with the above in mind.
* When you want to encode audio, prefer open, free formats like Ogg Vorbis. MP3 is not your friend.
* Never encode a lossy format to another lossy format. Always try to encode from a 96kHz, 24-bit FLAC if you can.
* Generally you won't have to touch PulseAudio, but there are a few things you can change in the `/etc/pulse/daemon.conf` file.
* You can pick a different resampling method, see the manual for your options.
* You should probably match the `default-sample-*` settings to your sound card.
* Generally you shouldn't touch this file unless you are experiencing sound issues.
* Do not set `avoid-resampling` to `true`, this is a huge misconception, this does not improve sound quality at best, and in the worst case, can actually break things.
As you can see, there's little you can do in Linux in the first place, so what can you do if you want better sound?
* Buy a good external DAC, turning a digital signal into analog inside of a PC case is a bad idea due to electromagnetic interference. Ever plugged your headphones into the front audio jack of your case? You will hear the noise. A good DAC will make a meaningful improvement your listening experience.
* Your headphones and amplifier really make the biggest difference. Having a good pair of headphones paired with a good headphone amplifier ten times more important than whatever chip you got in your PC.
**MYTH: Linux sound quality is worse than Windows.** They are exactly the same, Pulse doesn't work that different from how Windows does mixing and resampling.
**MYTH: Linux sound quality can be better than Windows.** They are exactly the same. All improvements in quality come from the driver and your DAC, not the sound server. Pulse and ALSA do not touch the PCM beyond moving it around and resampling it.
I hope this (long) guide was of help to you, and helped to dispell some myths. Did I miss anything? Ask or let me know, and I'll answer the best I can. Did I make any factual errors? Please correct me with a source and I'll amend the post immediately.
htt
The bit rate of an encoder means how much the audio will be compressed. PCM compression is super complicated, but it generally involves discarding silence, cutting off frequencies you cannot hear, and so forth. Radio encoding has a bit rate of roughly 128 Kbps, while most CDs have a bit rate of 170kBps~ (yes, bytes!)
Lastly, there is the concept of VBR and CBR. VBR stands for **V**ariable **B**it **R**ate, which CBR stands for **C**onstant Bit Rate. In a VBR encoding, the encoder aim for a target bit rate that you set, but it can deviate if it thinks it needs more or less. CBR will encode a constant bit rate, and will never deviate.
**MYTH: Lossless sounds better than lossy.** This is blatantly untrue, lossless audio formats were created for perservation and archival reasons. When you encode a lossy file from a lossless source, and you make sure that it's a 48kHz, 16-bit PCM encoding, you will not lose any important information. What is enough depends on the quality of the encoder. For OggVorbis, 192kbps is sufficient, for MP3, 256kbps should be preferred. 320kbps is excessive and the highest quality supported by MP3. In general, 256kbps does the trick, but with storage being abundant these days, you can play it safe and use 320kbps if it makes you feel better.
**MYTH: CBR is better than VBR.** There is no reason not to use VBR at all, there is no point in writing 256Kbps of data if there is only silence or a constant tone. Let your encoder do what it does best!
**FACT: Never encode a lossy format to another format.** You will compress data that is already compressed. This will always result in a further loss of data, even if the target format is a higher bit rate.
TL;DR, I JUST WANT THE BEST SOUND QUALITY
=========================================
Here is a quick guide to achieving great sound quality on Linux with the above in mind.
* When you want to encode audio, prefer open, free formats like Ogg Vorbis. MP3 is not your friend.
* Never encode a lossy format to another lossy format. Always try to encode from a 96kHz, 24-bit FLAC if you can.
* Generally you won't have to touch PulseAudio, but there are a few things you can change in the `/etc/pulse/daemon.conf` file.
* You can pick a different resampling method, see the manual for your options.
* You should probably match the `default-sample-*` settings to your sound card.
* Generally you shouldn't touch this file unless you are experiencing sound issues.
* Do not set `avoid-resampling` to `true`, this is a huge misconception, this does not improve sound quality at best, and in the worst case, can actually break things.
As you can see, there's little you can do in Linux in the first place, so what can you do if you want better sound?
* Buy a good external DAC, turning a digital signal into analog inside of a PC case is a bad idea due to electromagnetic interference. Ever plugged your headphones into the front audio jack of your case? You will hear the noise. A good DAC will make a meaningful improvement your listening experience.
* Your headphones and amplifier really make the biggest difference. Having a good pair of headphones paired with a good headphone amplifier ten times more important than whatever chip you got in your PC.
**MYTH: Linux sound quality is worse than Windows.** They are exactly the same, Pulse doesn't work that different from how Windows does mixing and resampling.
**MYTH: Linux sound quality can be better than Windows.** They are exactly the same. All improvements in quality come from the driver and your DAC, not the sound server. Pulse and ALSA do not touch the PCM beyond moving it around and resampling it.
I hope this (long) guide was of help to you, and helped to dispell some myths. Did I miss anything? Ask or let me know, and I'll answer the best I can. Did I make any factual errors? Please correct me with a source and I'll amend the post immediately.
htt
Exclude files when copying an entire directory
Multiple times we have come across that we need to copy an entire directory but excluding some files we don't want in the new directory. Well, we can accomplish that with RSYNC and some options easily:
rsync -av --exclude='*.out' /path/to/source/ /path/to/dest/
The above command will exclude all the files with ".out" extension.
**-a** : Recurse into directories i.e. copy all files and subdirectories.
**-v** : Verbose output.
​
Now, what if we want to send the files to another host? Well, we can use SSH:
rsync -av -e ssh --exclude='*.out' /path/to/source/ user@hostB:/path/to/dest/
I hope this will be useful for you.
https://redd.it/coigj2
@r_linux
Multiple times we have come across that we need to copy an entire directory but excluding some files we don't want in the new directory. Well, we can accomplish that with RSYNC and some options easily:
rsync -av --exclude='*.out' /path/to/source/ /path/to/dest/
The above command will exclude all the files with ".out" extension.
**-a** : Recurse into directories i.e. copy all files and subdirectories.
**-v** : Verbose output.
​
Now, what if we want to send the files to another host? Well, we can use SSH:
rsync -av -e ssh --exclude='*.out' /path/to/source/ user@hostB:/path/to/dest/
I hope this will be useful for you.
https://redd.it/coigj2
@r_linux
reddit
r/linux - Exclude files when copying an entire directory
0 votes and 2 comments so far on Reddit
My way to automount a samba share!
**INTRO**
I've been searching for a few weeks the best way to automount a samba share until I found this (the best?) method! The main problems were that when using fstab or a systemd mount then the whole system goes unresponsive when trying to access a mounted samba share which has gone offline (easily tested with disabling smbd on the server for few minutes and after a while you cannot even use ttys). Then I tried using autofs and experiment with various timeout options and stuff but I had the same problem. Finally, I tried an autostart noscript using `gio` (gvfs with fuse) but the performance was really bad and flatpaks apps weren't seeing the mount (had to add `override --filesystem=/run/user/1000/gvfs` and navigate to that location which isn't good).
**METHOD**
Lets say we have a server with IP [192.168.2.222](https://192.168.2.222) and a share named **pidata.**
1)Install cifs-client and smbclient (or samba-client on samba distros)
2)create file **/etc/smbcredentials** with the username and password of your samba share
username=USER
password=PASSWORD
`sudo chmod 600 /etc/smbcredentials`
3)Add to **/etc/fstab** the line
//192.168.2.222/pidata /media/pidata cifs credentials=/etc/smbcredentials,noperm,file_mode=0777,dir_mode=0777,iocharset=utf8,noauto,nofail 0 0
4) Create mount dir
`sudo mkdir /media/pidata`
5)Create executable file **/usr/local/bin/samba-mount**
#!/bin/bash
while true
do
smbup=$(smbclient -q -N -L 192.168.2.222 2> /dev/null)
smbup=$(echo $smbup | grep pidata)
if [[ -z $smbup ]]
then
umount -f -l /media/pidata &> /dev/null
else
if [[ -z $(mount | grep /media/pidata) ]]
then
mount /media/pidata &> /dev/null
fi
fi
sleep 15
done
6)Create /etc/systemd/system/samba-mount.service
[Unit]
Denoscription=Samba Mount
Wants=network.target
After=network.target
[Service]
Type=simple
ExecStart=/usr/local/bin/samba-mount
[Install]
WantedBy=multi-user.target
`sudo systemctl daemon-reload`
`sudo systemctl enable --now samba-mount`
**NOTES**
1)This method avoids system hangs comparing to just using just fstab or systemd mount (even autofs). However, applications which accessing files from a share which is going offline will probably break (system will be stable though).
2)Much better performance than gvfs/gio
3)Easy to show in all apps (gnome or kde) and sandboxed ones with the right permissions
4)You can avoid the fstab entry and just use the options at the mount command, but I prefer it that way in order to be able to easily mount it with terminal without needing to remember all these options
5)The options I use make the share accessible to all users but of course you can try different things.
6)At first I had added the option **users** at fstab to be able to mount it with any user, but that can lead to broken gui apps if you try to unmount a share which is down (tested with nemo), and also at many distributions only root user can run mount.cifs so better keep it that way.
7)If you change the samba-mount noscript then keep it as simple as possible. For example I was using `df -h` instead of `mount` to check if the share is already mounted, but apparently `df -h` also hangs and never finishes when the mounted share goes offline.
https://redd.it/cogxiv
@r_linux
**INTRO**
I've been searching for a few weeks the best way to automount a samba share until I found this (the best?) method! The main problems were that when using fstab or a systemd mount then the whole system goes unresponsive when trying to access a mounted samba share which has gone offline (easily tested with disabling smbd on the server for few minutes and after a while you cannot even use ttys). Then I tried using autofs and experiment with various timeout options and stuff but I had the same problem. Finally, I tried an autostart noscript using `gio` (gvfs with fuse) but the performance was really bad and flatpaks apps weren't seeing the mount (had to add `override --filesystem=/run/user/1000/gvfs` and navigate to that location which isn't good).
**METHOD**
Lets say we have a server with IP [192.168.2.222](https://192.168.2.222) and a share named **pidata.**
1)Install cifs-client and smbclient (or samba-client on samba distros)
2)create file **/etc/smbcredentials** with the username and password of your samba share
username=USER
password=PASSWORD
`sudo chmod 600 /etc/smbcredentials`
3)Add to **/etc/fstab** the line
//192.168.2.222/pidata /media/pidata cifs credentials=/etc/smbcredentials,noperm,file_mode=0777,dir_mode=0777,iocharset=utf8,noauto,nofail 0 0
4) Create mount dir
`sudo mkdir /media/pidata`
5)Create executable file **/usr/local/bin/samba-mount**
#!/bin/bash
while true
do
smbup=$(smbclient -q -N -L 192.168.2.222 2> /dev/null)
smbup=$(echo $smbup | grep pidata)
if [[ -z $smbup ]]
then
umount -f -l /media/pidata &> /dev/null
else
if [[ -z $(mount | grep /media/pidata) ]]
then
mount /media/pidata &> /dev/null
fi
fi
sleep 15
done
6)Create /etc/systemd/system/samba-mount.service
[Unit]
Denoscription=Samba Mount
Wants=network.target
After=network.target
[Service]
Type=simple
ExecStart=/usr/local/bin/samba-mount
[Install]
WantedBy=multi-user.target
`sudo systemctl daemon-reload`
`sudo systemctl enable --now samba-mount`
**NOTES**
1)This method avoids system hangs comparing to just using just fstab or systemd mount (even autofs). However, applications which accessing files from a share which is going offline will probably break (system will be stable though).
2)Much better performance than gvfs/gio
3)Easy to show in all apps (gnome or kde) and sandboxed ones with the right permissions
4)You can avoid the fstab entry and just use the options at the mount command, but I prefer it that way in order to be able to easily mount it with terminal without needing to remember all these options
5)The options I use make the share accessible to all users but of course you can try different things.
6)At first I had added the option **users** at fstab to be able to mount it with any user, but that can lead to broken gui apps if you try to unmount a share which is down (tested with nemo), and also at many distributions only root user can run mount.cifs so better keep it that way.
7)If you change the samba-mount noscript then keep it as simple as possible. For example I was using `df -h` instead of `mount` to check if the share is already mounted, but apparently `df -h` also hangs and never finishes when the mounted share goes offline.
https://redd.it/cogxiv
@r_linux
reddit
r/linux - My way to automount a samba share!
5 votes and 1 comment so far on Reddit
Deepin/ Terminal ROOT access
Hey guys, I use Deepin as my Linux distro, and everytime I open terminal and do something I have to use 'sudo' in order to be SuperUser. Would like to know is there a way to do and gain access to use terminal as a SuperUser/Root always?
https://redd.it/colgz0
@r_linux
Hey guys, I use Deepin as my Linux distro, and everytime I open terminal and do something I have to use 'sudo' in order to be SuperUser. Would like to know is there a way to do and gain access to use terminal as a SuperUser/Root always?
https://redd.it/colgz0
@r_linux
reddit
r/linux - Deepin/ Terminal ROOT access
0 votes and 1 comment so far on Reddit
Ten Open-Source Tools for Developers to Watch Out for in 2019
https://dzone.com/articles/ten-interesting-open-source-tools-for-developers
https://redd.it/coia39
@r_linux
https://dzone.com/articles/ten-interesting-open-source-tools-for-developers
https://redd.it/coia39
@r_linux
dzone.com
Ten Open-Source Tools to Watch Out for in 2019 - DZone Open Source
In this post, we take a closer look at the top ten emerging open-source tools right now, including tools for testing, development, prototyping, and more.
Keybindings with a ^ ..... what are they?
I'v been using Luke Smith's LARBS rice for I3, and I love it, but there is 1 thing I can not figure out ...
in some apps, there are keybindings with a \^
​
\^B \^t \^F and similar on newsboat, neomutt, etc, and I have tried every possible key and nothing works ... what is the \^ prefix on the keybinding? what key sequence am I supposed to push?
https://i.redd.it/dfguffzcgof31.png
https://redd.it/comuu9
@r_linux
I'v been using Luke Smith's LARBS rice for I3, and I love it, but there is 1 thing I can not figure out ...
in some apps, there are keybindings with a \^
​
\^B \^t \^F and similar on newsboat, neomutt, etc, and I have tried every possible key and nothing works ... what is the \^ prefix on the keybinding? what key sequence am I supposed to push?
https://i.redd.it/dfguffzcgof31.png
https://redd.it/comuu9
@r_linux
A simple unified keyboard automation tool for Wayland, X11, and Console
Introducing Hawck ([GitHub](https://github.com/snyball/Hawck).)
Linux with all it's combinations of window managers, display servers and desktop environments needs a key-rebinding system that works everywhere, and is simple to use.
Hawck intercepts key presses and lets you write Lua noscripts to perform actions or modify keys depending on your needs (see the GitHub page if you're running Wayland and are concerned about security.)
Your keyboard bindings will work on Wayland, X11, and every WM/DE you throw at them, as well as console ttys.
The ultimate goal of the project is to serve as a user-friendly Linux alternative to AutoHotkey, but this time with a sane noscripting language.
Want to make the caps lock key more useful, by binding it to control or escape?
key "caps" => replace "escape"
-- , or
key "caps" => replace "control"
Want to rebind caps-lock, but conditionally?
-- Pressing F7 will activate the replacement, and pressing F7
-- again will disable it.
mode("Caps => Ctrl mode", down + key "f7") + -up => {
key "caps" => replace "control"
}
Want to paste into a console tty, or a program that doesn't support pasting?
function getClipboard()
-- get-clipboard should be replaced with whatever works with your setup.
local p = io.popen("get-clipboard")
local clip = p:read("*a")
p:close()
return clip
end
shift + alt + key "v" => function ()
local clip_contents = getClipboard()
write(clip_contents)() -- Note the extra parens, write() returns a closure
end
Want to write "Hello" 10 times followed by a notification saying "World"? For, uh, some reason?
-- Note: down means that this will only activate when a key is pressed down.
-- You can also say `up + key "F12"` to activate on key-release, or
-- `-up + key "F12"` to activate on key-press and key-repeat.
down + key "F12" => (write "Hello ") * 10 .. say "World"
The noscripting language tries not to stray away from regular Lua syntax, but the extra operator `=>` was added.
More examples can be found on the GitHub page.
# How stable is it?
I've been running the master branch for a year without any problems. Your mileage may of course vary, depending on what you end up using it for.
Note that the Hawck GTK3 UI is still in an alpha state, and has a few unfinished/placeholder features, including "Simple Rebind." I've kept the "Simple Rebind" UI to get feedback on it.
# How do I install it?
Download or clone the git repo, and run the \`install.sh\` program from the command line (IMPORTANT: Don't use the .desktop file, you currently need to do it from the terminal.) This noscript has been tested for Ubuntu 18.04.
You will need to reboot the computer after running the installer, because it needs to add your user to a new group (with Ubuntu it seems like logging out and back in isn't enough.)
When you've started the computer back up again, run the following commands:
$ sudo systemctl start hawck-inputd
$ hawck-macrod
$ hawck-ui
PS: There is a known bug that sometimes causes \`hawck-ui\` to hang on startup, in that case, try agin.
Important note for people using sway, i3, openbox and similar minimal WMs: You need to have a [Polkit Authentication Agent](https://wiki.archlinux.org/index.php/Polkit#Authentication_agents) running to use the UI.
Move over to the settings tab, and change your keymap (this will hopefully be done automatically soon.)
You can now move on to the "Edit noscripts" tab and attempt to edit/enable the default test noscript.
If you want to keep using Hawck, and want to have it start up automatically, move over to Settings and click the autostart toggle button, you will be prompted for your password.
# I don't like the UI, can I use Hawck without it?
Sure.
To enable a noscript, create a symlink like so: `~/.config/hawck/enabled-s
Introducing Hawck ([GitHub](https://github.com/snyball/Hawck).)
Linux with all it's combinations of window managers, display servers and desktop environments needs a key-rebinding system that works everywhere, and is simple to use.
Hawck intercepts key presses and lets you write Lua noscripts to perform actions or modify keys depending on your needs (see the GitHub page if you're running Wayland and are concerned about security.)
Your keyboard bindings will work on Wayland, X11, and every WM/DE you throw at them, as well as console ttys.
The ultimate goal of the project is to serve as a user-friendly Linux alternative to AutoHotkey, but this time with a sane noscripting language.
Want to make the caps lock key more useful, by binding it to control or escape?
key "caps" => replace "escape"
-- , or
key "caps" => replace "control"
Want to rebind caps-lock, but conditionally?
-- Pressing F7 will activate the replacement, and pressing F7
-- again will disable it.
mode("Caps => Ctrl mode", down + key "f7") + -up => {
key "caps" => replace "control"
}
Want to paste into a console tty, or a program that doesn't support pasting?
function getClipboard()
-- get-clipboard should be replaced with whatever works with your setup.
local p = io.popen("get-clipboard")
local clip = p:read("*a")
p:close()
return clip
end
shift + alt + key "v" => function ()
local clip_contents = getClipboard()
write(clip_contents)() -- Note the extra parens, write() returns a closure
end
Want to write "Hello" 10 times followed by a notification saying "World"? For, uh, some reason?
-- Note: down means that this will only activate when a key is pressed down.
-- You can also say `up + key "F12"` to activate on key-release, or
-- `-up + key "F12"` to activate on key-press and key-repeat.
down + key "F12" => (write "Hello ") * 10 .. say "World"
The noscripting language tries not to stray away from regular Lua syntax, but the extra operator `=>` was added.
More examples can be found on the GitHub page.
# How stable is it?
I've been running the master branch for a year without any problems. Your mileage may of course vary, depending on what you end up using it for.
Note that the Hawck GTK3 UI is still in an alpha state, and has a few unfinished/placeholder features, including "Simple Rebind." I've kept the "Simple Rebind" UI to get feedback on it.
# How do I install it?
Download or clone the git repo, and run the \`install.sh\` program from the command line (IMPORTANT: Don't use the .desktop file, you currently need to do it from the terminal.) This noscript has been tested for Ubuntu 18.04.
You will need to reboot the computer after running the installer, because it needs to add your user to a new group (with Ubuntu it seems like logging out and back in isn't enough.)
When you've started the computer back up again, run the following commands:
$ sudo systemctl start hawck-inputd
$ hawck-macrod
$ hawck-ui
PS: There is a known bug that sometimes causes \`hawck-ui\` to hang on startup, in that case, try agin.
Important note for people using sway, i3, openbox and similar minimal WMs: You need to have a [Polkit Authentication Agent](https://wiki.archlinux.org/index.php/Polkit#Authentication_agents) running to use the UI.
Move over to the settings tab, and change your keymap (this will hopefully be done automatically soon.)
You can now move on to the "Edit noscripts" tab and attempt to edit/enable the default test noscript.
If you want to keep using Hawck, and want to have it start up automatically, move over to Settings and click the autostart toggle button, you will be prompted for your password.
# I don't like the UI, can I use Hawck without it?
Sure.
To enable a noscript, create a symlink like so: `~/.config/hawck/enabled-s
GitHub
GitHub - snyball/hawck: Key-rebinding daemon for Linux (Wayland/X11/Console)
Key-rebinding daemon for Linux (Wayland/X11/Console) - snyball/hawck
cripts/my-noscript.lua -> ~/.config/hawck/noscripts/my-noscript.lua`.
When you save a noscript in your editor, `hawck-macrod` will automatically reload it.
This currently means that you will not be able to use the `=>` operator. See the GitHub page for how the (very simple) translation is made.
# Why did you call it Hawck, don't you know how to spell?
The name Hawck is a portmanteau of "Hack" and "AWK." The noscripting language takes inspiration from AWK, and the whole project started out as a bit of a hack.
# Planned features
* Key-bindings made for a specific keyboard, so that users can turn their second keyboard into a macro-board.
* Sharing the keyboard between multiple machines (there are tools that do this, but AFAIK not on Wayland.)
https://redd.it/condg8
@r_linux
When you save a noscript in your editor, `hawck-macrod` will automatically reload it.
This currently means that you will not be able to use the `=>` operator. See the GitHub page for how the (very simple) translation is made.
# Why did you call it Hawck, don't you know how to spell?
The name Hawck is a portmanteau of "Hack" and "AWK." The noscripting language takes inspiration from AWK, and the whole project started out as a bit of a hack.
# Planned features
* Key-bindings made for a specific keyboard, so that users can turn their second keyboard into a macro-board.
* Sharing the keyboard between multiple machines (there are tools that do this, but AFAIK not on Wayland.)
https://redd.it/condg8
@r_linux
reddit
r/linux - A simple unified keyboard automation tool for Wayland, X11, and Console
0 votes and 5 comments so far on Reddit
Red Hat Joins The RISC-V Foundation
https://riscv.org/membership/6696/red-hat/
https://redd.it/coo09o
@r_linux
https://riscv.org/membership/6696/red-hat/
https://redd.it/coo09o
@r_linux
riscv.org
Red Hat - RISC-V International
Ubuntu file system corruption bug
https://www.cnx-software.com/2019/08/09/how-do-you-handle-backups-in-linux-hardware-software-configuration-etc/amp/
https://redd.it/conmoy
@r_linux
https://www.cnx-software.com/2019/08/09/how-do-you-handle-backups-in-linux-hardware-software-configuration-etc/amp/
https://redd.it/conmoy
@r_linux
CNX Software - Embedded Systems News
How Do You Handle Backups in Linux? Hardware, Software, Configuration, etc...
How do you handle backups in Linux on your side? What software & hardware combination do you use, and how often do you backup files from your PC?
How to install mx linux18 & add mate desktop
http://youtube.com/watch?v=Qit3yn3fbDI&app=desktop
https://redd.it/cons34
@r_linux
http://youtube.com/watch?v=Qit3yn3fbDI&app=desktop
https://redd.it/cons34
@r_linux
YouTube
Look @ MX Linux 18 - Install & Add Mate Desktop
Look @ MX Linux 18 - Install & Add Mate Desktop MX Linux has been released December 20, 2018. I take a look at installing it and adding the Mate desktop. It ...
How To Install Linux Mint 19.2
https://www.youtube.com/watch?v=RChbthrhrZw
https://redd.it/coiga4
@r_linux
https://www.youtube.com/watch?v=RChbthrhrZw
https://redd.it/coiga4
@r_linux
YouTube
How To Install Linux Mint 19.2
How To Install Linux Mint 19.2 Installing Linux Mint 19.2 ► Please subscribe help us to reach 10000 subscribers 🔶 https://www.youtube.com/c/MTSoftware?sub_co...
I think that I might want to replace the crouton chroot on my chromebook with an actual install of an operating system.
https://redd.it/cor6hy
@r_linux
https://redd.it/cor6hy
@r_linux
reddit
r/linux - I think that I might want to replace the crouton chroot on my chromebook with an actual install of an operating system.
0 votes and 1 comment so far on Reddit
Best apps for college student
I am running the latest ubuntu. I have found open office as a solid replacement for office. What other applications do you recommend for a college student?
https://redd.it/coraee
@r_linux
I am running the latest ubuntu. I have found open office as a solid replacement for office. What other applications do you recommend for a college student?
https://redd.it/coraee
@r_linux
reddit
r/linux - Best apps for college student
0 votes and 11 comments so far on Reddit
Submit your first Linux kernel patch in 6 minutes
I've recently looked into getting more into kernel development and found a lot of the information and guides out there quite verbose and confusing. I *hopefully* made a developer friendly article on how to hit the ground running on sending a kernel patch.
[https://medium.com/@adamzerella/how-to-become-a-linux-kernel-developer-20774c72ab07](https://medium.com/@adamzerella/how-to-become-a-linux-kernel-developer-20774c72ab07)
Let me know if anybody finds this type of content useful!
https://redd.it/cosb0x
@r_linux
I've recently looked into getting more into kernel development and found a lot of the information and guides out there quite verbose and confusing. I *hopefully* made a developer friendly article on how to hit the ground running on sending a kernel patch.
[https://medium.com/@adamzerella/how-to-become-a-linux-kernel-developer-20774c72ab07](https://medium.com/@adamzerella/how-to-become-a-linux-kernel-developer-20774c72ab07)
Let me know if anybody finds this type of content useful!
https://redd.it/cosb0x
@r_linux
Medium
How to become a Linux kernel developer
Coming in at approximately 77,000 files, 1,180,000 lines of C code and a 2.7 GB download, it’s no secret that engineers across the world…
KDE Usability & Productivity: Week 83
http://pointieststick.com/2019/08/10/kde-usability-productivity-week-83/
https://redd.it/cossrg
@r_linux
http://pointieststick.com/2019/08/10/kde-usability-productivity-week-83/
https://redd.it/cossrg
@r_linux
Adventures in Linux and KDE
KDE Usability & Productivity: Week 83
This week in KDE’s Usability & Productivity initiative is massive, and I want to start by announcing a big feature: GTK3 apps with client-side decorations and headerbars using the Breeze …
Is it bad that i use kali linux?
Like i wanted to learn cyber security and since i used debian in the past kali looked good but now eveybody calls me an idiot 12 year old try hard. Is kali linux bad or something???
https://redd.it/cosipu
@r_linux
Like i wanted to learn cyber security and since i used debian in the past kali looked good but now eveybody calls me an idiot 12 year old try hard. Is kali linux bad or something???
https://redd.it/cosipu
@r_linux
reddit
r/linux - Is it bad that i use kali linux?
0 votes and 13 comments so far on Reddit