• Breaking News

    [Android][timeline][#f39c12]

    Sunday, October 21, 2018

    Linux Useful command line tools and tips

    Linux Useful command line tools and tips


    Useful command line tools and tips

    Posted: 21 Oct 2018 04:17 AM PDT

    Hoping that this might help newcomers, in this post I present the tools I often use with some background why and how it can hopefully help you.

    I've started using Linux as my main OS in 2007 or 2008 with some trying it the years before and I remember that at the beginning, the shell is rather scary and mainly used to run commands that were copied from somewhere. I hope that you find some inspiration in this post to shift some of your workflow to the shell. Please understand that I won't give detailed usage examples, you can find those on the web easily, otherwise this post would become way too long.

    Also be aware that some examples might include functionality I mention later. Read the whole thing!

    In no particular order:

    tmux

    tmux is the Terminal MULtiplexer. What does that mean? Basically it allows you to divide a single shell window into multiple, which is the first thing it does. It can either be done using so-called windows (which is comparable to a browser's tab) and panes (which is comparable to a website's frame, though those are luckily not used anymore). This is useful when you have a limited number of shells available, but not only then.

    Another big advantage is that tmux allows you to keep programs running in the background that bind to a terminal. Sounds complicated, but let me explain what it means in practice. An executable you run from the shell will, by default if it doesn't do things to avoid it, bind to that terminal. That means if the terminal terminates / closes, the program terminates with it. However, there are situations where you don't want that, especially for long-running processes. To give an example: I have an encoding job in ffmpeg that takes multiple hours. I started it and now I want to close my session for whatever reason. However, if you close your session, your terminal terminates with it and your encoding stops. If you run that command in a tmux session, it will persist your logoff and keep running in the background and you can re-attach to your tmux session any time to see the progress of your encoding job.

    The other solution that you see sometimes is to run a command with an & at the end. This will make the process run in the background also; however you then have no easy way to reattach and interact with that process directly.

    There are a lot of great resources about tmux on the internet, so I'm not going into details here. My rule of thumb for using tmux is:

    1. Use it locally when you have a job that needs to run in the background
    2. Use it remote always (exceptions apply)

    OpenSSH

    ssh is the secure shell. What does it do? Everything honestly. You've probably used it to connect to another computer running it or know that it can do that. What else can it do for you? Frankly the name is a bit limiting as in fact, ssh offers more than just a shell. It can also act as a protocol to transfer files using the SFTP protocol securely over an insecure network. Other applications can use it to secure their connections, for example rsync. It can act as a SOCKS proxy. It has a lot of uses that might help you to get a task done.

    One example to show its versatility: I was in a hotel with my notebook and Raspberry Pi. I wanted to hook up the Raspberry Pi to the TV and use it to watch something over WiFi. The WiFi however had a login page for internet access and the Raspberry Pi no browser or peripherals and I wasn't willing to get either. So what did I do? I connected to the Raspberry Pi using ssh opening a SOCKS proxy (in this case the command is ssh -D 9999 $ip-address, then you set your SOCKS proxy in your browser to "localhost:9999" and browse a site. The network sees the Raspberry Pi requesting a website on the internet and presents you with the login page that is then delivered to your local browser. You accept the terms and the gateway now sees that the Raspberry Pi has accepted, whitelisting its MAC address and granting it internet access.

    ssh is great especially when combined with tmux. You can just connect to a remote server, start a tmux session by running tmux, do some stuff, detach from the tmux session, disconnect from the server, reconnect later, reattach the tmux session and everything is just as you left it plus any new output from running commands, if applicable. You can even do so in a manner that the session is started and re-attached to automatically on connecting.

    It is an awesome tool, but don't forget to secure it as it can allow access to your machine.

    Task Spooler

    One of the lesser known tools and maybe not helpful for many, Task Spooler helps you to run multiple shell commands after each other (or in parallel). The normal flow for a shell you might see is "command 1 & command 2 & command 3" which will run those commands after each other. But what if you don't know all the commands yet? Task spooler allows you to queue commands at any time, shuffle them around, change their running conditions (e.g. only run command if command with number 3 exited successfully) and more. I use it mostly to manage encoding jobs.

    find

    find is a tool for finding files using a plethora of criteria. It allows you to search for things like "files that have a certain age and are bigger than 4 GB" or whatever you might have in mind. In addition to just listing you those files, find also allows you to run a certain command on those files, either individually or on all of them in one go.

    If you don't need all the fancy knobs of find, fd is a faster and easier alternative.

    ffmpeg

    ffmpeg is basically the command line glue for all the multimedia codecs you have on your system. Firstly, it provides a lot of codecs by itself - in fact it's basically the project that developed most open source media codec implementations. It can, however, also use libraries from other projects, which is mostly interesting for encoding as ffmpeg's focus is not necessarily in depth, but breadth, which isn't a bad thing. It is an incredibly versatile tool to convert any media file to most relevant ones, though the quality of open source AAC encoders is lacking; however, I suggest avoiding it in general and go with OPUS, if possible.

    rsync

    Also one of the better-known tools, rsync is a tool that synchronizes files between two locations. What makes rsync so powerful are its delta algorithm to reduce transfer size and the transfer options. You can choose how the files are to be created on the receiving side, if the transfer should be done over SSH, if only newer files should be transfered, which mode they should be created in etc. It is the command line tool of choice for any general purpose data synchronization need like backups.

    sed

    The Stream EDitor transforms text. Sounds boring, but can be a very helpful tool. Silly example: I have a file called test.txt I want to post on reddit as code. Now I could use the editor and just select the lines I post, but that doesn't really convey the usefulness, so I'm going to do it my way and get the content of my file ready to post here from the command line:

    $ sed 's|^| |' < test.txt this is a line another one one more? let's keep going is this enough? running out of ideas anyhow it doesn't matter this line contains running as well end 

    This basically told sed to replace (or substitute, hence the "s") the beginning of each line it receives with four spaces, which it will then print to its standard output.

    grep

    Kind of related, grep takes input and outputs only the lines that match the filter criteria we gave it. To only print lines that start with "running":

    $ grep '^running' < test.txt running out of ideas 

    rename

    Probably you know that renaming individual files is done using the mv command. However, a dedicated command for renaming files exists. It is useful when you want to rename multiple files at once. A common example is that you have numbered files, say img1.jpg, img2.jpg, … img9.jpg, img10.jpg and so forth. Now the sorting here becomes a challenge because a shell might thing that img10.jpg comes after img1.jpg and before img2.jpg which is understandable and maybe even correct, but most certainly not what you want. rename helps with that. If you have less than a hundred files, this would fix your file names:

    $ rename img img0 img?.jpg 

    This translates to "rename img to img0 in all files that start with img followed by a single character followed by .jpg", so img1.jpg would become img01.jpg, but img10.jpg stays the same because it has two characters after "img" and before ".jpg".

    Be aware that two versions of rename exists, a simple one in C that is part of util-linux and a more powerful one written in Perl which supports Regular Expressions. The example I provided works in both though.

    Regular Expressions

    Regular Expressions or regex is a powerful system to match text. In fact it is so powerful that I don't think many have fully mastered it. and I am no exception - in fact my regex knowledge sucks. However, if you go back to the sed and grep example, the argument given there contains a regular expression, the ^ which translates to "beginning of line". This is certainly one of the easier ones, but Regular Expressions can become very complex, allowing you to match and transform text in a manner never experienced before ;)

    curl

    curl is a tool to download things in a non-interactive way. It is, in my opinion, the best one to use in scripts.

    Your shell

    Your shell is a tool to combine all the programs you have and make them do your bidding. It allows to be scripted for that matter and provides some logic itself. There are good shell scripting tutorials online and I suggest that you learn the basics (loops, conditional statements, general flow) as this is quite simple programming that can help to achieve some tasks.

    Conclusion

    As you noticed, this post doesn't really help with concrete problems, but this was not my goal. I hope to give a small overview of the tools you probably have installed on your system because for me as a beginner, it's not only that you don't know how a certain program works, but also that you don't even know it exists. Also, believe it or not, the shell and shell programs are tools to make your life easier, not harder, and after working with shell programs for some time, you'll most likely notice that they do what you want much better than most graphical programs. For sure not everything can be done efficiently in a shell, but a lot of tasks can. It requires some experience to analyze the problem you have into smaller sub-problems that you solve with the tools you have and combine using shell logic, but your tools are flexible and in my opinion, it's actually fun.

    If you need help on a given program, your first step should always be to run man $application, e.g. man rename which would explain the rename program including a slightly more complex version of the example I gave (meaning more than 100 files). If you try and you're not getting anywhere, feel free to ask, but always try to solve it yourself first.

    submitted by /u/DamnThatsLaser
    [link] [comments]

    Help with Apache

    Posted: 21 Oct 2018 01:10 PM PDT

    Hello,

    For my project I am trying to install apache web server. I needed apr and apr-util for the dependencies. and currently have both of the zipped files on my system. I was able to unzip the apr file using | tar -xzf apr-1.6.2.tar.gz. However when I tried to do the same with apr-util | tar -xzf apr-1.6.1.tar.gz . I can confirm that I am in the directory where the apr-util is stored and I am not making any spelling mistakes. I will attach the error message I am getting. Any feedback would be appreciated as I am currently lost.

    https://i.redd.it/wy6ktm3xilt11.png

    submitted by /u/king_y0ggi
    [link] [comments]

    Linux music player like Foobar

    Posted: 20 Oct 2018 11:13 PM PDT

    I love Foobar on Windows. The interface is incredible and easily customizable. Is there a Linux music app like Foobar ?

    submitted by /u/sivaptw
    [link] [comments]

    [Linux] How to use ls command to recursively display specific files using wildcards?

    Posted: 21 Oct 2018 11:20 AM PDT

    I'm trying to list all *.apk files in a directory including in its subdirectories. So, I thought of using below commandline.

    ls -R /storage/0000-0000/apks/*.apk 

    But it only displays the ones in /storage/0000-0000/apks. The ones in the subdirectories are not displayed.

    This is not a permission problem because I can access the files in the subdirectories.

    submitted by /u/jcunews1
    [link] [comments]

    TIL you can rotate the gears in glxgears

    Posted: 21 Oct 2018 01:20 AM PDT

    You can use the arrow keys to rotate the gears in a 3D space.

    submitted by /u/Esp724
    [link] [comments]

    Out of the newest Xubuntu, Peppermint, and Mint distros, which is the least likely to phone home with fishy stuff or give info to third parties?

    Posted: 21 Oct 2018 01:57 PM PDT

    I'm not really fussed with internet privacy. It's the enemy within. The telemetry, the amazon-style shenaningans that we have seen in ubuntu some years ago. I want to use xubuntu because it is lightweight, but it has a fishy software manager which loads ads and has non-free programs like spotify and other facebook-type programs, and it's just disgusting. Maybe it can be deleted. Peppermint looks super good, but someone said something about GNOME being shady, and it is partly based on that or something ,so I dunno. And Mint is popular for everyone, but I haven't informed myself enough to know how it stands with privacy.

    Ideally, I would like a distro that is ready to go out of the box, and I don't want any updates or any communication with any third parties, not for error reports or anything.

    Which one do I pick, and are there maybe better ones?

    tnx!

    submitted by /u/mipopoo
    [link] [comments]

    Post docker install, computer voice keeps telling me my distro flavor, vm flavor and "1 frame" over and over.

    Posted: 21 Oct 2018 01:41 PM PDT

    This began happening after I started working with docker via terminal to learn how to launch a new LEMP server. Is this a docker thing or I'm completely unsure what is doing it. Thanks!

    submitted by /u/d0tsun7
    [link] [comments]

    no wi-fi =/

    Posted: 21 Oct 2018 01:41 PM PDT

    i am in a Acer notebook, its have a button to turn on and off WI-FI, but this button don't operate when i boot the Notebook with puppy linux inside my pendrive, some one know where i turn on the Wi-Fi?

    submitted by /u/Rapiere_Gridoro
    [link] [comments]

    Need help installing Fail2ban on Netgear R700 router (tomato firmware)

    Posted: 21 Oct 2018 08:34 AM PDT

    I need help installing Fail2ban on my router. Most likely I would need USB storage, since nothing can be permanently changed on the system (I have tried with iptables for example).

    I just need help installing it, I couldn't figure out which flavor of linux this thing is, I only have this kernel version "2.6.36.4brcmarm".

    If I put the file on a USB stick, untar it and run the .sh is that all? How do I make it play nice with the system and iptables?

    Thank you

    EDIT: R7000 not R700

    submitted by /u/MalcolmY
    [link] [comments]

    Debian Basic Gnome Installation Guide + Development Tools

    Posted: 21 Oct 2018 11:55 AM PDT

    Hi.

    I've created a basic installation guide for Debian with the Gnome environment. I use this guide with every installation I do and I want to share it with the community. It is hosted on a Github repository cause it is a little bit large.

    Since I use the distribution for development I added a basic developer section.

    If you want to help to detect any kind of errors or contribute, you can send me a message or create an issue on the repository.

    Repository:
    https://github.com/alejandro-martin/debian-installation

    Github Page:
    https://alejandro-martin.github.io/d...ion/index.html

    submitted by /u/alex-wired
    [link] [comments]

    recording audio out of whats coming out of headphones?

    Posted: 21 Oct 2018 11:44 AM PDT

    Hiya - I cannot use the snap and the program is not in the software store of Audio recorder on my o/s.

    therefore I have to rely on some other program.

    I need specific info (not miggledied advice) about how to specifically record the music coming out of my headphones?

    I am on Solus OS - therefore audio recorder fails to work.

    submitted by /u/frankandgalculator
    [link] [comments]

    How to use a custom ASCII image in my terminal?

    Posted: 20 Oct 2018 06:25 PM PDT

    I'm on Ubuntu 18.04. I'm currently using screenfetch to display my sistem's specs and the distro logo. I've seen people have a custom ASCII image instead of the distro logo, but I'm not sure how I can do that. I couldn't find much information. Anyone know how?

    submitted by /u/xyzdig
    [link] [comments]

    Attempting to install Kubuntu, stuck on this screen

    Posted: 20 Oct 2018 09:35 PM PDT

    I took all the dual boot prerequisites, inserted my burned ISO disc. And now I have been stuck on this screenhttps://i.imgur.com/KtWE9Ke.jpg

    I can move the mouse freely around, but there's nothing here. On the PC's bootup, there were a couple basic text screens that lasted a couple seconds, but I was never asked to install or anything. What gives?

    edit: Nevermind, I just realized my 2nd monitor was shut off and the installation window was there.... lol

    submitted by /u/PrettyTonyTiger
    [link] [comments]

    I EXTRACTED 10.000 FILES TO MY DESKTOP...

    Posted: 20 Oct 2018 05:42 PM PDT

    and now my x220 is dying. it was vpn configuration files and it made my computer alow down because they didnt all fit on desktop.

    i restartet my pc during the process and now i cant even delete the files from the desktop...

    any chance anyone here happen to know what i can do. id appreciate greatly

    submitted by /u/crptgd
    [link] [comments]

    Booting Kubuntu from USB gets stuck

    Posted: 21 Oct 2018 09:20 AM PDT

    I've been trying to install Kubuntu 18.04.1 onto a USB flash drive via Universal USB Installer, but whenever I try to boot from the USB, my laptop gets stuck on the startup screen (white "Ubuntu" with a blue glow around it, and the glow doesn't change).

    The flash drive has a 8 GB storage capacity which should be enough for the OS and 4 GB of persistent memory according to Universal USB Installer.

    This is the very first time I'm using Linux, so any help would be appreciated.

    submitted by /u/xx_l0rdl4m4_xx
    [link] [comments]

    From Proxmox CLI, I can ping 8.8.8.8 but I can't curl google.com

    Posted: 21 Oct 2018 08:44 AM PDT

    So right now, I'm essentially tearing down the whole network and rebuilding it from the ground up. All that's plugged in right now is my cable modem (not a router), which goes into a dual-NIC mini-PC running Proxmox with a running pfsense VM, and a pi-hole VM that isn't spun up yet. The LAN cable is going to a 20-port managed switch, and my desktop is plugged into that switch. I'm typing this from my desktop, so obviously my desktop has Internet, pfsense is working fine, I can access the proxmox web GUI just fine, but when I drop into the proxmox shell and try to update, it just times out. But I can ping 8.8.8.8 and get a good response. When I try to curl google.com, it hangs and times out, so obviously, DNS is the culprit, right? I tried adding the pfsense VM as a dns-nameserver to the interfaces file, restarted networking.service, nothing. Tried rebooting the whole machine. Nothing. I've been Googling how to manually set DNS in proxmox, and I guess my Google-Fu is weak, because I can't find anything beyond editing /etc/network/interfaces and setting "dns-nameserver" in there.

    Any ideas what's wrong, here?
    Thanks!

    **EDIT: SOLVED! I'm an idiot. I forgot that Proxmox keeps DNS settings in its own separate tab from the rest of the network settings in the web GUI. I just updated the web GUI DNS settings, and everything works fine. Thanks for all the help guys! I'll leave this up in case anyone else makes this stupid mistake, lol!

    submitted by /u/gregorthebigmac
    [link] [comments]

    Ubuntu 18.10 GNOME, somehow managed to break the Terminal Shortcut

    Posted: 21 Oct 2018 01:50 AM PDT

    As per title. CTRL+ALT+T does nothing, and rebinding the shortcut also does nothing. Resetting does nothing. Apparently I can install Arch but not use a Shortcut properly.

    submitted by /u/Clubjustin
    [link] [comments]

    Absolute tracking trackpad on Kubuntu?

    Posted: 21 Oct 2018 01:20 AM PDT

    Back when I was using HellOS, i used this software that changed my trackpad from relative tracking to absolute tracking and can be changed back easily by closing the program. Is there something similar in Kubuntu 18.04? I've heard about using evdev absolute tracking but it looks like a permanent solution and I want a temporary one.

    ps: graphical interface would be nice

    i am using it to play osu!

    submitted by /u/mrlacpeanut
    [link] [comments]

    Google Chrome on Linux mint 18.4 , is not saving my extension(s) settings or oneTab extension urls.. gets lost after every few weeks

    Posted: 21 Oct 2018 04:53 AM PDT

    On linuxmint 18.4 , Google Chrome is not saving my extension saved settings , or oneTab extension urls.. gets lost after every few weeks. is there something i can do to make my extension settings and onetab extension urls saved/persistent. Im not sure what is actually causing this loss of saved settings of my extensions/cache data. btw i have not updated Chrome for the reason, which i thot was possibly the issue,but even without updating Chrome my saved settings for extensions are loosing their saved values and each time i have to configure noscript urls and similarly for all other extensions

    i know i can export oneTab urls but dont want to do it each time i open/close browser.

    appreciate any suggestions on how i can fix this issue.

    submitted by /u/white_swan
    [link] [comments]

    How can I change my username and computer name in Linux Mint 19?

    Posted: 21 Oct 2018 04:15 AM PDT

    I've seen a few tutorials saying I need to edit the etc/hostname file, but I can't find it.

    Looked in the "File system" folder and also on the "Home" folder (after pressing Ctrl+H and seeing all hidden folders there).

    As for the username I changed it on "System Settings"->"Account Details", but when I go to "Users and Groups" the old name still displays below the new one on the right side of the picture. How can I change that?

    Could someone please let me know how to do it properly?

    Thank you!

    submitted by /u/RTQMARK
    [link] [comments]

    how do i mount a share manually that i have in /etc/fstab?

    Posted: 20 Oct 2018 06:38 PM PDT

    I have this in my /etc/fstab file.

    It is supposed to auto connect on startup but it has never worked that way so I would have to force it.

    The problem is that I don't remember how i would force it... I think i used sudo mount -a but that doesn't seem to be working. Any ideas?

    submitted by /u/Auroroz
    [link] [comments]

    Users Lack Permissions to Share Subdirectories Created by Docker

    Posted: 21 Oct 2018 02:26 AM PDT

    I run qBittorrent in a docker on my Unraid server, downloading to several different shares.

    It's working well, except that apparently any directories created by the docker are seemingly owned by the user running the docker (UID 99, apparently), and they don't respect the permissions I've set up for the share.

    For example, while bob may have full read/write access to the share /software/, he cannot change a subdirectory like /software/nameoflinuxdistro/ if it was created by the docker as part of a torrent.

    To change such a directory, I have to do it either through the docker (ie qBittorrent's webui) or a terminal as root. This is untenable.

    How do I ensure that any files or directories created by the docker inherit the permissions I've set up for the share?

    submitted by /u/explodingpens
    [link] [comments]

    Getting Plank to lock Docklets at the end of Dock, ala MacOS

    Posted: 21 Oct 2018 01:37 AM PDT

    Basically I have been trying to get this to work all day long, but can't manage to do it. I want to have a separator at the end of the Dock to place my Trash Applet, but hours of Ducking (and Googling) have led me nowhere. Ubuntu 18.10.

    submitted by /u/Clubjustin
    [link] [comments]

    How to delete redundant/no longer needed installs?

    Posted: 20 Oct 2018 04:50 PM PDT

    I have several installations of wine in particular that I'd like to get rid of. I'm on Mint 19. Just not sure how to find the files and delete them or find the program within Mint that will allow me to delete whole packages at once.

    submitted by /u/tokeholdlaunch
    [link] [comments]

    No comments:

    Post a Comment

    Fashion

    Beauty

    Travel