PlutoParty

joined 1 year ago
MODERATOR OF
[–] PlutoParty 6 points 5 months ago

There are giant swaths of area with no coverage, especially in the mountains of arizona, including the freeways and especially highways. The entire western US can be spotty with signal out in the great wide open. It isn't until the Midwest and more east that one should largely not worry about signal coverage anymore.

[–] PlutoParty 7 points 5 months ago (2 children)

What is a non-mechanical mechanical part?

[–] PlutoParty 5 points 5 months ago

Wouldn't Trump being elected change that? You don't even make sense.

[–] PlutoParty 2 points 5 months ago* (last edited 5 months ago)

Maybe it is my ad blocker that is filtering this kind of stuff for me. Or maybe the things I look up most often are specific enough that there isn't much bullshit or clickbaity stuff to show. Sure, I'll see the occasional "Sponsored" link. I think my brain just auto-filters those and I don't even take notice. I really don't intend to sound like a Google fanboy - I'm not. I just don't seem to experience this, but hear people say this a lot. The attached screenshot seems like a typical result for something I'd look up, and it's exactly what I'm looking for. In any case, thanks for your perspective. I'm going to try to be more conscious to see if I'm just fooling myself.

[–] PlutoParty 4 points 5 months ago* (last edited 5 months ago) (3 children)

As a programmer and system admin, I've been using Google since its inception, too. I can't think of an instance that I've failed to find whatever I'm looking for in recent times. People say what you're saying a lot, so I don't doubt you. It just makes me wonder what it is you guys are searching for because I search for some extremely obscure stuff quite often with no issues. This is all to say, I have a fair share of qualms with Google, but the search engine itself isn't one of them.

[–] PlutoParty 2 points 5 months ago (1 children)

There's really not much to it. I don't understand why you're so dumbfounded such a thing is possible. People steal or buy up formula. Those who steal it make a profit no matter what price they sell it at. Those who live in an area where it sells out have the ability to mark it up big time. Paying 10 extra bucks is better than driving hours away with the hope they have it in stock there. People will sell it on offerup, craigslist, facebook, etc. Search for "formula" offerup if you're in the US and you'll likely see it. This was especially a problem during Covid and we saw the same scheme extend to many other products. In 2022, there was a massive shortage for the better part of a year. Any that came around got bought up immediately - by some that were lucky enough to get it at the right time and the rest by scalpers. This is not a new thing and I find it surprising that you're so surprised. I often see them locked up and purchase limits at the store because of this.

[–] PlutoParty 1 points 5 months ago* (last edited 5 months ago) (3 children)

Holy naivete, my sweet summer child. This has nothing to do with conservatives. This is a well-known scheme that is problematic in many areas.

[–] PlutoParty 4 points 9 months ago (2 children)

Doesn't make much sense to me, the way you used it. An example of nepotism might be if you gave your drug dealer a job instead of other candidates just because he is your drug dealer. Doing drugs with employees isn't necessarily nepotism.

[–] PlutoParty 6 points 10 months ago

Google Maps is always dead on for me. I regularly drive very long distances across the US. The time estimates are within minutes of accurate even when there are sudden or extreme backups like in Los Angeles. There's plenty to criticize Google for, but it isn't Google maps for me.

[–] PlutoParty 4 points 11 months ago* (last edited 11 months ago) (1 children)

Despite autopilot's flaws, this is already true, if we are speaking statistically.

[–] PlutoParty 2 points 11 months ago

If you intend to operate a commercial vehicle with air brakes, you do have to take an air brake skills test in Wisconsin.

[–] PlutoParty 1 points 11 months ago

Very few agencies would do more than roll their eyes at such a report.

 

Today's tip is a simple one many experienced users will roll their eyes at, but that is because it is so common and handy to use. When watching and helping people new to Linux, I often see them fail to utilize this powerful tool. They struggle to remember file names and commands and it hurts my soul to watch knowing how much easier it could be for them. Knowing how to use this helps you help yourself. There isn't a day that goes by I don't use this probably a hundred times.

Tab completion

Tab completion is a powerful feature in the Linux terminal that allows you to quickly complete filenames, directory paths, and commands by pressing the 'Tab' key. It can significantly speed up your workflow and reduce the chances of typos.

Benefits of using tab completion:

  • Efficiency: Saves time by reducing typing and minimizing errors.
  • Discoverability: Helps you discover available commands and file/directory names.
  • Accuracy: Reduces typos and potential mistakes.

Using Tab Completion

Completing Commands: Type the start of a command, maybe one you can't quite remember the name of, and press 'Tab' twice to see a list of available commands that match the entered text. If you've typed enough that there will only be one option, it'll complete that one for you.

Completing Filenames and Directories: When typing a file or directory name, press 'Tab' to automatically complete the name. If multiple options match, pressing 'Tab' twice will display the options.

Navigating Directories: Use tab completion to navigate through directories quickly. For example, type cd /usr/l and press 'Tab' to complete to /usr/local/.

Conclusion

It should be noted that tab completion may work slightly different depending on the terminal and other settings you may have. Pressing 'Tab' twice may bring up a full menu to select from for available files or directories, for instance. However, this overview provides the gist of how it works for most any system I regularly come across.

 

Today's tip is on customizing the terminal prompt. If you're a developer, there is a high chance that you use source control. There's also a high chance that source control is git. You likely find yourself in and out of project directories, navigating different branches quite often. One customization I like to make to my prompt is adding the git branch I'm currently working in, if one exists. This is far from the only customization that can be made, but I'm going to cover because it is so common and relatable to many.

Understanding the Default Prompt

The default prompt usually includes your username, hostname, and current directory. It might look like:

user@hostname:~/current_directory$

The cool thing is you can set this to whatever you'd like - or nothing at all. Some of those things might be an indicator that shows whether you are working on a remote or local machine, cpu load and other system stats, or the time. If you want to pull the water temperature from a buoy in the Gulf of Mexico and you'd find that useful in your prompt, you can add that, too. You can also stylize your prompt with colors. You can even create a multi-line prompt with some of these on each line using the new line escape sequence (detailed below).

The prompt is simply the value of the PS1 environment variable. To view your current one, you can run echo $PS1

Changing the Prompt Temporarily:

You can change your prompt temporarily by assigning a new value to the PS1 environment variable:

PS1="MyFirstCustomPrompt$ "

This will change your prompt to MyFirstCustomPrompt$ until you close the terminal.

Customizing with Escape Sequences:

You can use escape sequences to add color, time, date, and more to your prompt. Here are the escape sequences:

  • \u: Current username

  • \h: Hostname

  • \w: Full current working directory

  • \W: Last part of the current working directory

  • \d: Date (e.g., Fri Aug 11)

  • \t: Time (24-hour format, 14:30:00)

  • \n: New line

  • \e[x;ym: This sequence is used to set foreground and background colors. Replace x and y with color codes from below.

Color Codes

  • 0 : Reset / No color
  • 1: Bold / Bright
  • 2: Dim / Faint
  • 3: Italic
  • 4: Underlined
  • 5: Blinking
  • 7: Inverted colors (swap foreground and background)
  • 8: Hidden / Concealed

Foreground Color Codes:

  • 30: Black
  • 31: Red
  • 32: Green
  • 33: Yellow
  • 34: Blue
  • 35: Magenta
  • 36: Cyan
  • 37: White

Background Color Codes:

  • 40: Black
  • 41: Red
  • 42: Green
  • 43: Yellow
  • 44: Blue
  • 45: Magenta
  • 46: Cyan
  • 47: White

For example:

PS1="[\e[1;32;41m\u@\h \W\e[m]$ "

This displays your prompt in green on a red background (ugly), including the username (\u), hostname (\h), and current directory (\W).

Git Branch Function and Make Changes Permanent:

To make your custom prompt permanent, add the PS1 assignment to your shell's profile configuration file (~/.bashrc for Bash, ~/.zshrc for Zsh).

To add the current git branch to the prompt, you'll need to include a function that parses the git branch for the current directory. If there is a git branch, the function returns the value to be displayed. This is what you'd add at the end of your configuration file.

parse_git_branch() {
   git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}

PS1="\[\e[1;32m\][\u@\h \W\$(parse_git_branch)]\[\e[m\]$ "

This code defines parse_git_branch that extracts the current branch from a Git repository and adds the branch information to the prompt.

Conclusion

Using this method, there are all sorts of creative prompts that can be created. If you use or know of any handy prompts or come up with any after reading this, please share in the comments.

28
submitted 1 year ago* (last edited 1 year ago) by PlutoParty to c/linux4noobs
 

What is tmux?

tmux, short for terminal multiplexer, is a command-line tool that allows you to split your terminal into multiple panes, create and manage multiple terminal sessions, and attach and detach to them. It allows you to create multiple terminals in one window.

What's the point?

The feature I appreciate most is the attach and detach functionality. I manage a multitude of servers running an array of services and tasks. There are instances where my internet connection acts up while I'm working remotely and I get disconnected. Losing my shell environment and any ongoing processes due to a hiccup in my internet is frustrating and can be time consuming.

Working within a tmux session allows me to reconnect, attach to my session, and seamlessly pick up right where I left off without sacrificing any progress. Another nice thing is that I can effortlessly move to another workstation and resume my session on a remote machine there. I find it particularly useful to detach and send certain processes to the background. While testing and developing, I often choose this approach in lieu of setting up a systemd service. What many people will do is create a script that launches a service in a tmux session, which allows for attaching to it at some point later to either interact or view any output from what is running easily.

If it is hard to conceptualize the value of this, you can think of it as having many terminal windows open that you can minimize and come back to later.


Using tmux

There are a lot of tmux features and shortcut keys, but I'm going to cover the ones I regularly use that fit my needs. As with most things in Linux, there are several ways to accomplish the same task. Here is a handy cheatsheet of tmux commands. Try not to be overwhelmed with the amount of shortcuts. I certainly don't have them all memorized. If you're like me, you'll have just a few you regularly use and it'll become muscle memory after a short time.

Installing

Not all systems will have tmux installed by default, but it is very likely in the package manager as tmux. sudo dnf install tmux, sudo apt install tmux, or sudo pacman -S tmux will likely get the majority of people there, depending on which system and package manage is in use.


New Session

The most simple way to start a tmux session is to simply run tmux. This will create the virtual session with a generic name. I prefer to name my sessions so I can easily identify them if I get several sessions going. This makes it easy to identify what is what. I start my sessions with tmux new-session -s sessionname


Detach Session

To detach from this session, you press Ctrl+b then d . That session is now running in the background and whatever process you were running, if any, are still running. You'd be free to end the ssh connection if that is how you are connected and that session will still remain alive.


Listing, Attaching and Switching Sessions

To list your running sessions while not in a tmux session, you can run tmux ls. To attach to one of these sessions by name, you can run tmux a -t sessionname. What I often do out of laziness after connecting to a machine is simply run tmux a. This will join the last session you were attached to or sometimes it feels like it just selects a random one. From there, pressing Ctrl+b, s will open a list of all the running sessions you can easily select and jump to with the arrow keys and pressing enter. This is my normal workflow, but again, there are several ways to accomplish the same thing and even several variants of the commands, as can be seen on the cheatsheet link above.


Killing a Session

The usual way that I kill a session is to just run exit while inside of the one I wish to end. As noted on the cheatsheet, there are other ways to kill it without actually entering it.


Scrolling

The only other common feature I use is scrolling. While inside a session, you lose the ability to easily scroll back as you normally would in a terminal emulator such as terminator or konsole. To scroll back up you use Ctrl+b [. You can then use the arrow keys to scroll above what is presently on the screen. Ctrl+c gets you out of scrolling mode. Be careful to only Ctrl+c once, as you might unintentionally kill a running process if there is one going.


Conclusion

This is how I usually use tmux. It'll be useful to look at the cheatsheet and play around with some of the other features you might find handy, such as creating panes and windows.

Another popular multiplexer that accomplishes a lot of these same tasks is screen. screen is older but many still find it just as useful.


I'm curious how other people utilize tmux. Are there any lesser known tips or tricks that I didn't cover or may not know about? Better methods that'd make my workflow as described above easier? Does anyone have a strong opinion on using screen instead of tmux? Any considerations or dangers that people should be aware of when using a multiplexer? If so, let us know!

36
submitted 1 year ago* (last edited 1 year ago) by PlutoParty to c/linux4noobs
 

I thought it might be nice to start a daily tips & tricks post to stimulate some conversation while offering up fundamental knowledge to those who might appreciate it. And it gives me something to get my brain going with my morning coffee. I intend for them to be very brief (this turned out to be a lie) and serve as a starting point for anyone who may wish to dig deeper through their own research or discussion.

Feel free to add any additional thoughts or questions in the comments. Certainly please correct me if I make any mistakes. If there are any topic requests for future tips & tricks, throw them out there or if you have one of your own you'd like to share, please post it. I'll try to post and/or feature one daily. If I don't have time to write my own and no one else has offered anything up, I'll find something interesting elsewhere to feature.


File Permissions and Ownership

Understanding permissions and ownership for files and directories gives you granular control over who can access and modify your files. Understanding this is especially essential for security and privacy. I'll be working in the terminal to explain:

View Permissions

To view permissions, run ls -l. This outputs a long listing of the files in your current directory. The information in the far left column are the permissions. It should be noted that everything in Linux is treated as a file, including directories. This isn't technically true, but you can think of it this way for our purposes here.

drwxr-xr-x is an example of permissions for one of my directories I'll refer to as funny_memes.

Permission Symbols
  • d = directory
  • r = read
  • w = write
  • x = execute
  • - = not set (or regular file)

For our purposes, you can ignore the first character. Most commonly you'll see 'd' or '-' to denote it being a directory or a regular file. There are also others you may wish to explore (symlinks, sockets, etc).

The 3 groups we are interested in each contain 3 characters. That is, 3 groups of 3. (I know this is confusing, but "group" is one of the groups of 3.) The order of these groups are 'user', 'group', and 'others'. That order is specific and important to remember. To use my funny_memes example, my current permissions are set as follows:

~$ ls -l

drwxr-xr-x. 1 PlutoParty PlutoParty 0 Aug 9 04:08 funny_memes

Type User Group Others
d rwx r-x r-x

This means the user who owns this directory can read, write, and execute. The group assigned to this directory can only read and execute. And all others can also only read and execute.

Ownership

In the ls -l output, the user and group assigned to the directory (or file) is displayed just after the permissions, in that order. In my example, PlutoParty is my user and PlutoParty is the group of the funny_memes directory.

Changing permissions

Octal Notation

Permissions can be changed with chmod using octal or symbolic notation. Understand the 3 bit octal notation is a little tricky to understand at first. In short, for each group (user, group, and others) the sum of the bits set determines the file permission. Individual permission bits are as follows:

  • 'r' (Read): 4
  • 'w' (Write): 2
  • 'x' (Execute): 1

If I wanted to give execute and read permission only to a user, group, or to others, for example, that permission value would be 5. (1 + 4). Full permissions would be 7. Read and write only would be 6. This works because every combination is a unique sum.

Here is a cheat sheet of all the combinations for reference:

Octal Value Permissions
0 No permissions
1 Execute only
2 Write only
3 Write and execute
4 Read only
5 Read and execute
6 Read and write
7 All permissions

The user, group, and others each get a value set. To change my funny_memes directory to full permissions for user, group, and others, I'd set that with chmod 777 funny_memes. Again, each number represents the sum of the permission bits you want assigned for user, group, and others, individually and in that order. 777 gives full permission to each of them because 4 (read) + 2 (write) + 1 (execute) = 7.

If I want to only allow the user full permissions (myself, in this case) and deny group and others anything, I'd run chmod 700 funny_memes. One more example is if I wanted to allow the user to read and write while only allowing the group and others to read, I'd use chmod 644 funny_memes

For many people, this is tricky to remember and understand at first. So, don't get frustrated. Write the individual permission bits down (read, write, and execute - not the full cheat sheet) from above and use it. You'll quickly have it memorized. It's really only 3 numbers to memorize. If you memorize those and remember that the order is user, group, others, you'll be a master at setting permissions with octal notation by the end of the day. In my opinion, it is actually easier than setting with symbolic notation, which we'll get familiar with now.

Symbolic Notation

  • u : owner of the file.
  • g : group associated with the file.
  • o : users who are not the owner or part of the group (others).
  • a : all users (or you can also use ugo combined).

Permissions:

  • r (read)
  • w (write)
  • x (execute)

Operators:

  • + : Adds a permission.
  • - : Removes a permission.
  • = : Sets the specified permissions and removes any others.

If we had a script called do_backup.sh and we want to set the permissions for the owner to execute, the group to read, and deny others from any permissions, we'd run chmod u+x,g+r,o- do_backup.sh. You can add or remove permissions individually in this manner. You can also combine u, g, or o as needed if they will have identical permissions. I think this is handy for 'fine tuning' any permissions, but it is a bit (hehe) of a pain to type it all out in comparison to 3 numbers that can quickly be added up in your head.

Changing Ownership and Conclusion

In order to change the owner and group of a file (which you may need elevated permissions to do depending on existing permissions), I'll leave you to explore the chown and chgrp commands. They are pretty straightforward, but do offer more advanced options you can read about in the man pages.

And that's really the basics of assigning permissions. To explore more, I'd suggest reading the man pages on the following commands:

  • man chmod
  • man chown
  • man chgrp

Those really interested may want to go on to read about creating and managing groups.

32
Welcome to linux4noobs! (programming.dev)
submitted 1 year ago by PlutoParty to c/linux4noobs
 

Post your questions relating to the installation, configuration, & usage of Linux without fear of sounding dumb.

The only dumb question is the one you don't ask!

view more: next ›