Tag: python
November 10, 2022
2022 11 10 Python 3.11 Error Reporting
Went to a Python meetup today where the new features in Python 3.11 were discussed. Among them was of course the new nifty error reporting. It was noted that the error reporting does NOT work when using the REPL, but only when running a script through the interpreter.
It wasn’t immediately apparent why that was, so I wanted to do a little bit of digging and see if I could find anything about it.
November 1, 2022
Shebang issue - Ubuntu does not link 'python' to 'python3' by default
I typically use #!/usr/bin/env python as my shebang for Python stuff. I switched to Ubuntu (22.04) from Fedora (36) recently and found that when I tried to run something outside of a virtualenv it bombed out thusly:
/usr/bin/env: ‘python’: No such file or directory This stackoverflow post offered two solutions:
sudo ln -s /usr/bin/python3 /usr/bin/python
sudo apt install python-is-python3
The post that presented the latter pointed me at the package’s description:
May 19, 2021
Python Decorators
On the subject of Decorators. Right now my brain is feeling overwhelmed and I wonder if I bit off more than I could chew. Not sure exactly which is best to start with but I’ll first go for the how and follow up with some of the why.
Also this article assumes some knowledge of decorators already. It’s not intended to be a full course on how they work or the motivation behind them (though I attempt to shed light on both).
May 10, 2021
Interesting Python Split Behavior
Had a recent challenge that didn’t hold me up for long. I tried what was the correct solution on a whim and it happened to work, but I wanted to analyze the behavior. The goal was to build a function that accepts a string and modifies it according to the examples:
"This is an example!" ==> "sihT si na !elpmaxe" "double spaces" ==> "elbuod secaps" The characters in each individual word are reversed, the ordering of the words are preserved as are the number of spaces between words.
May 3, 2021
Variadic Arguments
I’m currently working on a challenge that needs to check for an arbitrary amount of arguments.
The Python docs have info on some so-called ‘variadic arguments’ which are what I seem to need to be using. The idea is to use these fancy *args and **kwargs arguments which then allow one to pass as many positional or keyword arguments as desired and just handle them within the function when/if they are present.
April 30, 2021
List Comprehension
Well here I go again re-learning some stuff. I love list comprehension. I just did a challenge on some website where the description was:
The main idea is to count all the occurring characters in a string. If you have a string like aba, then the result should be {‘a’: 2, ‘b’: 1}.
What if the string is empty? Then the result should be empty object literal, {}.
So I of course went through and did my for loop, and nested an if/else within and some other stuff that wasn’t terribly elegant.
April 29, 2021
Python for loop over a dictionary
Jeeze, just had to remind myself of this. I got the blog up and going again to be able to note stuff like this down so here we go.
For loops on a dictionary in Python. There’s an option of looping over it raw, or include the use of its methods: keys(), values(), items().
When looping over it raw, you just get the keys back (makes me wonder why keys() exists in the first place, but that’s a lesson for another day):
November 14, 2017
Sublime Text 3 builder for Python 3
I didn’t know this but there’s this thing in Sublime Text 3 referred to as a “builder” that basically lets you run some code against whatever file/project you’re in.
The reason I’m using this is because I hate having a separate terminal open to run a script I’m working on. Instead I can just use ctrl+b and it’ll run the code and display the output in a window at the bottom of my Sublime window.
June 1, 2016
Python local variables
Apparently variables are local to a given function simply by virtue of being defined within said function. No keyword needed:
def f(): s = 'some value' print(s) ERROR: You fool! s isn't defined!!
Tag: fedora
November 1, 2022
Shebang issue - Ubuntu does not link 'python' to 'python3' by default
I typically use #!/usr/bin/env python as my shebang for Python stuff. I switched to Ubuntu (22.04) from Fedora (36) recently and found that when I tried to run something outside of a virtualenv it bombed out thusly:
/usr/bin/env: ‘python’: No such file or directory This stackoverflow post offered two solutions:
sudo ln -s /usr/bin/python3 /usr/bin/python
sudo apt install python-is-python3
The post that presented the latter pointed me at the package’s description:
Tag: shebang
November 1, 2022
Shebang issue - Ubuntu does not link 'python' to 'python3' by default
I typically use #!/usr/bin/env python as my shebang for Python stuff. I switched to Ubuntu (22.04) from Fedora (36) recently and found that when I tried to run something outside of a virtualenv it bombed out thusly:
/usr/bin/env: ‘python’: No such file or directory This stackoverflow post offered two solutions:
sudo ln -s /usr/bin/python3 /usr/bin/python
sudo apt install python-is-python3
The post that presented the latter pointed me at the package’s description:
Tag: ubuntu
November 1, 2022
Shebang issue - Ubuntu does not link 'python' to 'python3' by default
I typically use #!/usr/bin/env python as my shebang for Python stuff. I switched to Ubuntu (22.04) from Fedora (36) recently and found that when I tried to run something outside of a virtualenv it bombed out thusly:
/usr/bin/env: ‘python’: No such file or directory This stackoverflow post offered two solutions:
sudo ln -s /usr/bin/python3 /usr/bin/python
sudo apt install python-is-python3
The post that presented the latter pointed me at the package’s description:
Tag: decorators
May 19, 2021
Python Decorators
On the subject of Decorators. Right now my brain is feeling overwhelmed and I wonder if I bit off more than I could chew. Not sure exactly which is best to start with but I’ll first go for the how and follow up with some of the why.
Also this article assumes some knowledge of decorators already. It’s not intended to be a full course on how they work or the motivation behind them (though I attempt to shed light on both).
Tag: nginx
April 26, 2021
Nginx reverse proxy
I can’t believe it was this easy. I always got overwhelmed by having to learn how to do a reverse proxy in Nginx (or any other capable software), but I found myself needing to do it to get this blog up and going again since I had multiple things that would need port 80 in my system. Basically something like this in my site’s config file under site-confs:
server { listen 80; root /config/www/; server_name scooterx3.
Tag: webhosting
April 26, 2021
Nginx reverse proxy
I can’t believe it was this easy. I always got overwhelmed by having to learn how to do a reverse proxy in Nginx (or any other capable software), but I found myself needing to do it to get this blog up and going again since I had multiple things that would need port 80 in my system. Basically something like this in my site’s config file under site-confs:
server { listen 80; root /config/www/; server_name scooterx3.
Tag: im
December 10, 2017
Pidgin Bonjour
I just learned that Pidgin can do serverless, no-configuration LAN instant messaging by using a Bonjour “account”. All you need to do is add an account as normal, select “Bonjour” from the dropdown and add a username. I also had to punch a hole in the firewall of the computers I was using (tcp, check account “advanced” settings tab for port number). Specifically, when one person wanted to initiate a conversation with another, that other person’s firewall needed to be open.
Tag: pidgin
December 10, 2017
Pidgin Bonjour
I just learned that Pidgin can do serverless, no-configuration LAN instant messaging by using a Bonjour “account”. All you need to do is add an account as normal, select “Bonjour” from the dropdown and add a username. I also had to punch a hole in the firewall of the computers I was using (tcp, check account “advanced” settings tab for port number). Specifically, when one person wanted to initiate a conversation with another, that other person’s firewall needed to be open.
Tag: networking
December 6, 2017
TCP/IP stack
The TCP/IP stack is a networking model that describes what happens to data in transit from one application to another.
How does it differ from OSI? The TCP/IP stack is just another model, similar to OSI. At the end of the day, TCP/IP stack aims to describe the same thing that OSI does. It’s just a different description. Like learning the same subject from two different people.
The layers: Application Transport IP Link Application This layer defines what data is to be sent and “encodes” it so that the receiving application can understand it.
January 7, 2017
And then it dawned on me
Had to write this down. I’ve been trying to get up and going with KVM recently. I got a break from school and need KVM up on my home server so I can experiment with many other things. I read through a bunch of the libvirt documentation, specifically about virt-install, and then once I had a grasp I ran through some tutorials. Most of the tutorials I found out there and virt-install one-liners had me using a network option as follows:
July 5, 2016
Centos 7 firewall
Just a quick note, I had to open up a hole in the firewall on the server itself (even though I had my router stuff all set right already) by doing:
<i>sudo firewall-cmd --permanent --zone=public --add-port=80/tcp sudo firewall-cmd --reload </i> Worked great. I guess having a firewall on the server itself is good too. Instead of just relying on the one on the outer edge of the network.
June 13, 2016
SSH to virtualbox server
So I have been trying to figure this out. I am supposed to be able to do some port forwarding, which isn’t hard, but it wasn’t working. Eventually I went with the option of setting up two network adapters, one set up on NAT (so the VM can access the www) and another as a host-only, so the host can access the guest on 192.168.x.x
I was having a problem though, it was refusing me.
May 31, 2016
Netcat
Just was playing around with it, wanted to write a few things down. I typically use telnet to test for a particular port. Essentially the basic usage is:
nc some.domain.com 21 That will connect to some.domain.com on port 21 if possible. What I want to use it for though is to just quickly check a series of ports. Here’s the command I like currently:
nc portquiz.net 21 -zv the -z only checks for connection, but /dev/nulls any response from the server.
Tag: bash
July 19, 2017
Process Substitution - Missing File Descriptors
I work with many servers each day, and more often than not I wind up sourcing a script or two from one of my remote servers, thusly:
. <(curl -Ss https://mygitrepo.whatever/repo/file.sh) Now and then the server complains by responding:
bash: /dev/fd/63: No such file or directory I went googling and found that actually it’s not a very uncommon thing to have happen. It turns out the symlink /dev/fd > /proc/self/fd was missing.
April 25, 2017
tr - translate or delete characters
purpose the tr command is for “translating” (replacing or deleting) characters in a string. Accepts input from stdin, and puts output on stdout. I am bold about characters because it’s not got a way to specify that you want to replace one string with another string (use sed for that).
examples single character replacement The basic usage on tr is to just replace one character with another. It’s case-sensitive:
echo "aAbBcCdD1234" | tr 1 R aAbBcCdDR234 #only the '1' was replaced with 'R' character set replacement One can specify a set of characters to be replaced by a set of others:
December 10, 2016
Why my PS1 sucked and what I did about it.
I always had problems with my PS1 variable. It would show up like this (in green):
username@boxname:[~/Documents] $ The idea was to have something bright to easily see the prompts while scrolling back up, and drop down a new line so I could allow the directory path to get as long as needed without reducing the amount of space I had to type in. Though the PROBLEM I had with it was that it prevented me from properly editing a command retrieved from history by pushing the up arrow on the keyboard.
December 9, 2016
Get rid of prefix/suffix bash
Sometimes a dude just needs to get rid of a prefix or a suffix:
string=some_database-file.sql suffix=.sql stuff=${string%$suffix} echo $stuff get rid of prefix using ‘#’: ${string#$prefix}
get rid of suffix using ‘%’: ${string%$prefix}
June 29, 2016
piping and redirection
xargs – takes results from one command and uses them as arguments to another command.
<command1> | xargs <command2> tee – takes stdin and prints to file and prints to screen. Thus to be able to capture and see output
<command1> | tee <filename> Redirection
<command> > file.txt 2>&1 This sends stdin and stdout’s output to file.txt
June 27, 2016
stdin, stdout and stderr
Redirecting
stdin is a channel where one provides input (keyboard, typically)
stdout is a channel that a script or program uses to output information
stderr is another channel used by a script or program to output errors
< redirect stdin
redirect stdout
2> redirect stderr
Examples:
This redirects any errors to the ‘err’ file
ls nonexistentfile 2> err This redirects any actual output to the ‘out’ file and errors to ‘err’
June 16, 2016
Environment variables
The only thing I really need to know is that this command displays all of them from the current session:
env<del></del> But I guess I’ll write down some other stuff too.
The ‘export‘ command makes a variable available to any children of the current session. That’s the only real reason that it should be used. Otherwise you can prepend to the path for instance using:
PATH=/home/myself/bin/:$PATH You can unset variables using the ‘unset‘ command
June 16, 2016
BASH one-line if
I recently learned about this:
(( 1 )) && echo "true" || echo "false" Which is a great way to do an if statement on a single line, if you ask me. I could just do if [[ cond ]]; do something else; another thing; fi but I think this one is pretty slick.
[[ cond ]] && <what happens if true> || <what happens if false>
June 16, 2016
BASH step values
This is cool, I can use this syntax:
{<start>..<end>..<increment>} To step through numbers! Like this:
$ echo {1..10..2} 1 3 5 7 9 It works in loops, or any old thing! Awesome!
June 14, 2016
Escaping characters in echo
I knew of this option:
echo -e "\042asdf\042" # this prints ("asdf") but never realized that one could also:
echo $'\042asdf\042' # this also prints ("asdf") I don’t even know what to call that…
June 1, 2016
Bash variables
So apparently $variable is actually a simplified form of ${variable}. Now I know! http://www.tldp.org/LDP/abs/html/varsubn.html
I’m considering making that my standard code, if that’s how they’re supposed to be…
Tag: file descriptors
July 19, 2017
Process Substitution - Missing File Descriptors
I work with many servers each day, and more often than not I wind up sourcing a script or two from one of my remote servers, thusly:
. <(curl -Ss https://mygitrepo.whatever/repo/file.sh) Now and then the server complains by responding:
bash: /dev/fd/63: No such file or directory I went googling and found that actually it’s not a very uncommon thing to have happen. It turns out the symlink /dev/fd > /proc/self/fd was missing.
Tag: process substitution
July 19, 2017
Process Substitution - Missing File Descriptors
I work with many servers each day, and more often than not I wind up sourcing a script or two from one of my remote servers, thusly:
. <(curl -Ss https://mygitrepo.whatever/repo/file.sh) Now and then the server complains by responding:
bash: /dev/fd/63: No such file or directory I went googling and found that actually it’s not a very uncommon thing to have happen. It turns out the symlink /dev/fd > /proc/self/fd was missing.
Tag: binary
July 16, 2017
Binary Conversion
This is a method I learned recently, figured I’d write it down.
Start with the number that you’re trying to convert. Divide it by two. If the result is even, leave a zero behind and put the result to the left of the original number. If the result is odd, put the result minus the remainder to the left and leave a one behind.
Basically, even results get a 0, odd results get a 1.
Tag: math
July 16, 2017
Binary Conversion
This is a method I learned recently, figured I’d write it down.
Start with the number that you’re trying to convert. Divide it by two. If the result is even, leave a zero behind and put the result to the left of the original number. If the result is odd, put the result minus the remainder to the left and leave a one behind.
Basically, even results get a 0, odd results get a 1.
Tag: automation
July 14, 2017
Bitbucket Pipelines
Pipelines are a way to automate tasks when committing to a git repo (and more). Generally I’ve viewed them as a good way to deploy as soon as you commit. I suppose there are other uses for them though. I’d never used pipelines, but had always wanted to fire up a Jenkins server to mess around with it. But it seemed overwhelming and honestly I had trouble justifying the time. The other day though, I noticed that Bitbucket has a new-ish pipelines feature!
Tag: git
July 14, 2017
Bitbucket Pipelines
Pipelines are a way to automate tasks when committing to a git repo (and more). Generally I’ve viewed them as a good way to deploy as soon as you commit. I suppose there are other uses for them though. I’d never used pipelines, but had always wanted to fire up a Jenkins server to mess around with it. But it seemed overwhelming and honestly I had trouble justifying the time. The other day though, I noticed that Bitbucket has a new-ish pipelines feature!
July 29, 2016
Git server
Had trouble figuring out how to clone from a private git server. As long as git is installed, you can create a repository, then pull from it using:
git clone ssh://user@host/~user/repo/ or you could also:
git clone ssh://user@host/home/user/repo/ But it just doesn’t do relative paths (except for the ~user/ part)
Tag: umask
May 14, 2017
Umask-again
The umask command/utility is a bash builtin. It’s used to check and/or alter the file-creation mode mask.
What’s a Mode Mask? A mode mask is just a little bit of information (an octal value) that defines what permissions a file or directory is set with when created. It’s generally stored/set in octal form and follows the same rules as the chmod command in terms of read/write/execute permissions are specified. The big difference though is that the octal form is a complement.
September 23, 2016
Umask
What in the heck is it? How does it work? The umask is a way to determine for a given user what the permissions of newly created files and directories have. Supposedly Linux wants 666 and 777 to be default perms for files and directories, respectively. Notice when you make a file, it’s set to 644, and directories to 755 though. That’s because this umask value is taking effect. On my machine anyway, the default umask is 022 (—-w–w-).
Tag: package management
May 12, 2017
Yum
The yum (Yellowdog Updater, Modified) tool was a rewrite of another tool called yup (Yellowdog UPdater). It’s just an RPM-based package manager, good for installing and removing software (including dependencies) from one’s system in a safe, easy manner. People liked it, it eventually just became “the thing to use” on RPM-based systems (such as Fedora and family, Yellow Dog itself, and tons others).
Their homepage is at yum.baseurl.org.
Repositories To function, Yum relies on repositories (‘repos’ for short) which are locations online that store RPM packages.
May 10, 2017
RPM Package Manager
RPM has been around since 1997, per Wikipedia. Originally was known as Red Hat Package Manager, but now just stands for RPM Package Manager. Here’s a quick overview on it.
RPM Archive Naming Scheme Example:
<name>-<version>-<build>.<architecture>.rpm ----- xbill-2.1-6.fc24.x86_64.rpm The above is largely self-explanatory, but for clarity, the <build> field is for either the number of times the package has been rebuilt (I’m not sure how that’s useful) or it’s for indicating the specific distribution the package is intended for (very useful, IMO).
June 14, 2016
Unpacking RPM files
rpm2cpio and yumdownloader
If you ever happen to want to get some files from an RPM to do whatever you want with them, you could:
yumdownloader <package> rpm2cpio <package.rpm> > file.cpio cpio -idv < file.cpio # extracts from file.cpio all package files into the current working dir Pretty simple and small, but a good tool to have if you need it.
June 13, 2016
YUM and RPM
RPM = Redhat Package Manager
YUM = Yellowdog Updater Modified
Yum is different from APT in that it automagically does an update of the local cache when you’re checking a repository for whatever.
Some YUM commands
yum search yum info yum install yum remove yum provides # shows what package provided a particular binary, file, etc yum update Important paths:
/etc/yum.conf # some configuration for yum, including the directory where repos are stored /etc/yum.
June 10, 2016
APT
Sources lists found in:
/etc/apt/sources.list /etc/apt/sources.list.d/* Apt-get and apt-cache commands go hand-in-hand, whereas aptitude is new and kinda rolls them into one.
There’s a script called:
dpkg-reconfigure which can walk one through the initial setup of a package that they’d have found when they first installed a package.
Tag: rpm
May 12, 2017
Yum
The yum (Yellowdog Updater, Modified) tool was a rewrite of another tool called yup (Yellowdog UPdater). It’s just an RPM-based package manager, good for installing and removing software (including dependencies) from one’s system in a safe, easy manner. People liked it, it eventually just became “the thing to use” on RPM-based systems (such as Fedora and family, Yellow Dog itself, and tons others).
Their homepage is at yum.baseurl.org.
Repositories To function, Yum relies on repositories (‘repos’ for short) which are locations online that store RPM packages.
May 10, 2017
RPM Package Manager
RPM has been around since 1997, per Wikipedia. Originally was known as Red Hat Package Manager, but now just stands for RPM Package Manager. Here’s a quick overview on it.
RPM Archive Naming Scheme Example:
<name>-<version>-<build>.<architecture>.rpm ----- xbill-2.1-6.fc24.x86_64.rpm The above is largely self-explanatory, but for clarity, the <build> field is for either the number of times the package has been rebuilt (I’m not sure how that’s useful) or it’s for indicating the specific distribution the package is intended for (very useful, IMO).
June 14, 2016
Unpacking RPM files
rpm2cpio and yumdownloader
If you ever happen to want to get some files from an RPM to do whatever you want with them, you could:
yumdownloader <package> rpm2cpio <package.rpm> > file.cpio cpio -idv < file.cpio # extracts from file.cpio all package files into the current working dir Pretty simple and small, but a good tool to have if you need it.
June 13, 2016
YUM and RPM
RPM = Redhat Package Manager
YUM = Yellowdog Updater Modified
Yum is different from APT in that it automagically does an update of the local cache when you’re checking a repository for whatever.
Some YUM commands
yum search yum info yum install yum remove yum provides # shows what package provided a particular binary, file, etc yum update Important paths:
/etc/yum.conf # some configuration for yum, including the directory where repos are stored /etc/yum.
Tag: yum
May 12, 2017
Yum
The yum (Yellowdog Updater, Modified) tool was a rewrite of another tool called yup (Yellowdog UPdater). It’s just an RPM-based package manager, good for installing and removing software (including dependencies) from one’s system in a safe, easy manner. People liked it, it eventually just became “the thing to use” on RPM-based systems (such as Fedora and family, Yellow Dog itself, and tons others).
Their homepage is at yum.baseurl.org.
Repositories To function, Yum relies on repositories (‘repos’ for short) which are locations online that store RPM packages.
June 14, 2016
Unpacking RPM files
rpm2cpio and yumdownloader
If you ever happen to want to get some files from an RPM to do whatever you want with them, you could:
yumdownloader <package> rpm2cpio <package.rpm> > file.cpio cpio -idv < file.cpio # extracts from file.cpio all package files into the current working dir Pretty simple and small, but a good tool to have if you need it.
June 13, 2016
YUM and RPM
RPM = Redhat Package Manager
YUM = Yellowdog Updater Modified
Yum is different from APT in that it automagically does an update of the local cache when you’re checking a repository for whatever.
Some YUM commands
yum search yum info yum install yum remove yum provides # shows what package provided a particular binary, file, etc yum update Important paths:
/etc/yum.conf # some configuration for yum, including the directory where repos are stored /etc/yum.
Tag: usb
May 8, 2017
Lsusb Basics
Just a quick reference of:
basic output filter by bus/device filter by vendor/product Basic Output The lsusb tool just reads the USB bus and lists what it finds. Super flashy.
Here’s my computer. I’ve only plugged in one flash drive and a mouse:
$ lsusb Bus 002 Device 003: ID 8086:0189 Intel Corp. Bus 002 Device 004: ID 046d:c077 Logitech, Inc. M105 Optical Mouse Bus 002 Device 002: ID 8087:0024 Intel Corp.
Tag: man
May 3, 2017
Man Pages
RTF(ull)M
This makes me think of the the paper manuals that came inside of a box with the game cartridge back in the day. They taught one about the game, how to play, and gave helpful information to make one’s questing more enjoyable. Well, the “man pages” are like those manuals, but for commands/packages/software on a Linux system.
Using The Manual You can view pages from the manual using:
man <page> Where <page> is the name of the page you want.
Tag: cut
April 26, 2017
cut - remove sections from each line of files
purpose This prints to stdout selected parts of lines from either files or stdin, and spits them out on stdout. It can select byte ranges, character ranges and fields based on delimiters.
bytes I’m still working out what actual use cases are for this, but here’s a basic example using the -b flag:
$ echo 'El Niño' | cut -b 1 E #since 'E' is 1 byte long, and I wanted the first byte of the string, it returned 'E' I can do a range:
Tag: paste
April 26, 2017
paste merge lines of files
The purpose of the paste command is to merge lines of files together. So for instance between file1 and file2, the default behavior is to paste the lines of the files side by side with a tab between them.
file a:
the quick brown fox jumped over the dirty, soggy log the cow jumped over the moon the dish ran away with the spoon that one guy put his wife in a pumpkin some kid's head got all big because he pulled a plum out of a pie file b:
Tag: tr
April 25, 2017
tr - translate or delete characters
purpose the tr command is for “translating” (replacing or deleting) characters in a string. Accepts input from stdin, and puts output on stdout. I am bold about characters because it’s not got a way to specify that you want to replace one string with another string (use sed for that).
examples single character replacement The basic usage on tr is to just replace one character with another. It’s case-sensitive:
echo "aAbBcCdD1234" | tr 1 R aAbBcCdDR234 #only the '1' was replaced with 'R' character set replacement One can specify a set of characters to be replaced by a set of others:
Tag: users
April 24, 2017
User and Group Management Cheat Sheet
“I fight for the users!” -Tron
Just a basic syntax cheat-sheet, for things I’d most likely use these for.
useradd -c: add a comment (typically used for the user’s full name) -d: specify home directory (but this doesn’t necessarily create it) -m: create home diretory -r: system account (for things like Apache where it’s best to run under a user acct) usermod -a: append; adds user to groups (only use with -G option) -c: overwrite current comment -d: specify new home direcctory -G: a list of groups that the user is a member of (overwrites the list unless used with -a) -L: lock password (this won’t block SSH with a key) -m: move home (move user’s home to a new location) groupadd -r: system groupmod -n: new name for the group
June 7, 2016
sudo or wheel
I just found out that in some systems (looking at centOS 7 currently) have a ‘wheel’ group, which supposedly is the equivalent of the ‘sudo’ group on my Ubuntu install. Wheel is something old-school that stuck around. Meant “big wheel” which apparently was something like “big cheese”, which also doesn’t make sense but they mean “someone with power” or “in charge”.
Tag: processes
April 12, 2017
Fork and Exec
I was just trying to understand Exec a bit better, specifically in scripting. I went down a small rabbit hole, and I’m not sure I’m any closer to understanding the purpose of exec in scripting yet, but I just had a lightbulb that I figured I should write down. My objective is to show the relationship between fork and exec, and what exec’s purpose is.
Let’s start with some random process.
October 10, 2016
Process state reference
Processes states that ps indicate are:
D Uninterruptible sleep (usually IO) R Running or runnable (on run queue) S Interruptible sleep (waiting for an event to complete) T Stopped, either by a job control signal or because it is being traced. W paging (not valid since the 2.6.xx kernel) X dead (should never be seen) Z Defunct ("zombie") process, terminated but not reaped by its parent. and the additional characters are:
Tag: filesystems
March 25, 2017
symlinks and hardlinks
ls creates symlinks and hardlinks (use the -s flag for a symlink) symlinks are identified by the ‘l’ in the attributes of a file (random example from my current machine): lrwxrwxrwx. 1 riley riley 33 Oct 3 08:29 .xbindkeysrc -> /home/riley/dotfiles/.xbindkeysrc drwxrwxr-x. 4 riley riley 4096 Mar 24 08:42 xdrive -rw-rw-r--. 1 riley riley 26918 Oct 9 08:31 .xfce4-session.verbose-log Notice the first one has an ‘l’ in it, that means it’s a symlink (but also the stuff on the far right makes it obvious).
Tag: linking
March 25, 2017
symlinks and hardlinks
ls creates symlinks and hardlinks (use the -s flag for a symlink) symlinks are identified by the ‘l’ in the attributes of a file (random example from my current machine): lrwxrwxrwx. 1 riley riley 33 Oct 3 08:29 .xbindkeysrc -> /home/riley/dotfiles/.xbindkeysrc drwxrwxr-x. 4 riley riley 4096 Mar 24 08:42 xdrive -rw-rw-r--. 1 riley riley 26918 Oct 9 08:31 .xfce4-session.verbose-log Notice the first one has an ‘l’ in it, that means it’s a symlink (but also the stuff on the far right makes it obvious).
Tag: bridge
January 7, 2017
And then it dawned on me
Had to write this down. I’ve been trying to get up and going with KVM recently. I got a break from school and need KVM up on my home server so I can experiment with many other things. I read through a bunch of the libvirt documentation, specifically about virt-install, and then once I had a grasp I ran through some tutorials. Most of the tutorials I found out there and virt-install one-liners had me using a network option as follows:
Tag: kvm
January 7, 2017
And then it dawned on me
Had to write this down. I’ve been trying to get up and going with KVM recently. I got a break from school and need KVM up on my home server so I can experiment with many other things. I read through a bunch of the libvirt documentation, specifically about virt-install, and then once I had a grasp I ran through some tutorials. Most of the tutorials I found out there and virt-install one-liners had me using a network option as follows:
Tag: vm
January 7, 2017
And then it dawned on me
Had to write this down. I’ve been trying to get up and going with KVM recently. I got a break from school and need KVM up on my home server so I can experiment with many other things. I read through a bunch of the libvirt documentation, specifically about virt-install, and then once I had a grasp I ran through some tutorials. Most of the tutorials I found out there and virt-install one-liners had me using a network option as follows:
Tag: regex
December 9, 2016
Various capture group methods
Just wanted to write one or two of these, maybe more as time goes on:
egrep:
egrep -o "(['\"])root\1" This one I wanted to get either a ‘ or a ” before the word “root” and then find the closing one, whichever it was. The key here is that with egrep you have to surround the statement in quotes, the opening/closing parentheses don’t need escaping, and use a backslash followed by a number to denote the group
Tag: monitors
November 17, 2016
Quick xrandr script
Just wanted to write down that I created a quick method for a coworker to fix her monitors when she docked her laptop. The problem was that XFCE (she’s using Xubuntu 16.04) wasn’t remembering the monitor’s settings. When she docked the laptop, she had to manually put things back using the GUI for monitor settings. I wrote a quick script something like this:
#!/bin/bash xrandr --output <monitor 1> --auto xrandr --output <monitor 2> --auto xrandr --output <monitor 3> --auto xrandr --output <monitor 2> --right-of <monitor 1> --output <monitor 3> --right-of <monitor 2> The names were different, I retrieved them from her system using xrandr -q.
Tag: x
November 17, 2016
Quick xrandr script
Just wanted to write down that I created a quick method for a coworker to fix her monitors when she docked her laptop. The problem was that XFCE (she’s using Xubuntu 16.04) wasn’t remembering the monitor’s settings. When she docked the laptop, she had to manually put things back using the GUI for monitor settings. I wrote a quick script something like this:
#!/bin/bash xrandr --output <monitor 1> --auto xrandr --output <monitor 2> --auto xrandr --output <monitor 3> --auto xrandr --output <monitor 2> --right-of <monitor 1> --output <monitor 3> --right-of <monitor 2> The names were different, I retrieved them from her system using xrandr -q.
Tag: xrandr
November 17, 2016
Quick xrandr script
Just wanted to write down that I created a quick method for a coworker to fix her monitors when she docked her laptop. The problem was that XFCE (she’s using Xubuntu 16.04) wasn’t remembering the monitor’s settings. When she docked the laptop, she had to manually put things back using the GUI for monitor settings. I wrote a quick script something like this:
#!/bin/bash xrandr --output <monitor 1> --auto xrandr --output <monitor 2> --auto xrandr --output <monitor 3> --auto xrandr --output <monitor 2> --right-of <monitor 1> --output <monitor 3> --right-of <monitor 2> The names were different, I retrieved them from her system using xrandr -q.
Tag: kernel modules
October 5, 2016
Fedora 24 VMware workstation 12
When VMware gets installed, it checks to make sure the proper kernel modules are installed when first run. It fails for me on Fedora24. I am not savvy when it comes to these things so I had to go digging. I found this resource:
http://vcojot.blogspot.com/2015/11/vmware-worksation-12-on-fedora-core-23.html
Which worked wonderfully. Basically I had to run this script that the author of the article made, which as I understand altered vmware files. Then I ran vmware-modconfig to go ahead and allow vmware to update kernel modules for me, which it did with no problem.
Tag: vmware
October 5, 2016
Fedora 24 VMware workstation 12
When VMware gets installed, it checks to make sure the proper kernel modules are installed when first run. It fails for me on Fedora24. I am not savvy when it comes to these things so I had to go digging. I found this resource:
http://vcojot.blogspot.com/2015/11/vmware-worksation-12-on-fedora-core-23.html
Which worked wonderfully. Basically I had to run this script that the author of the article made, which as I understand altered vmware files. Then I ran vmware-modconfig to go ahead and allow vmware to update kernel modules for me, which it did with no problem.
Tag: guest additions
October 5, 2016
Virtualbox Guest Additions for Kali Linux
I just started goofing off with Kali Linux (metasploit against a metasploitable image) and had installed it to virtualbox. I tried to install Guest Additions so as to be able to make the screen match my actual monitor and allow for fullscreening. In trying to do that, I was told I needed kernel headers for the 4.7 kernel, but the Kali I just installed (2016.2 version) was running on the 4.
Tag: virtualbox
October 5, 2016
Virtualbox Guest Additions for Kali Linux
I just started goofing off with Kali Linux (metasploit against a metasploitable image) and had installed it to virtualbox. I tried to install Guest Additions so as to be able to make the screen match my actual monitor and allow for fullscreening. In trying to do that, I was told I needed kernel headers for the 4.7 kernel, but the Kali I just installed (2016.2 version) was running on the 4.
June 13, 2016
SSH to virtualbox server
So I have been trying to figure this out. I am supposed to be able to do some port forwarding, which isn’t hard, but it wasn’t working. Eventually I went with the option of setting up two network adapters, one set up on NAT (so the VM can access the www) and another as a host-only, so the host can access the guest on 192.168.x.x
I was having a problem though, it was refusing me.
Tag: hardware
October 2, 2016
turn off extra buttons Dell N411Z
I’ve got a Dell N411Z laptop. Nothing flashy, and it got dropped on one corner so when I adjust the tilt of the screen, the broken hinge triggers a button, which randomly sends a signal for the letter ‘x’ to whatever app is active at the time. Here are my notes to get it to quit doing that.
install ‘xbindkeys’ (available in main repositories for both Ubuntu and Fedora). You have to find out what the ‘signal’ looks like to xbindkeys, do so by running xbindkeys -k It tells you then to push a key.
Tag: linux
September 28, 2016
/opt vs /usr/local
I just realized that both are places that one might put software not “native” to a system. I found this post and here are the main points to get the gist:
/usr/local is a place to install files built by the administrator, typically by using the make command. The idea is to avoid clashes with files that are part of the operating system…
On the other hand, /opt is a directory for installing unbundled packages, each one in its own subdirectory.
September 23, 2016
Process management
I was recently asked how to show threads instead of PIDs using the ‘ps’ command. I wanted to find out why that’s even desired in the first place. I don’t have experience dealing with such things. I did learn new things, but still don’t really know why one would care about listing the threads. Can one manipulate them? Wouldn’t it cause erratic behavior? Is the killing of individual threads of a process allowed from outside?
September 20, 2016
File types in linux
Just a quick reference
Regular file (-) Directory (d) Symlink (l) Named pipe (p) Socket (s) Character device (c) Block device (b)
August 22, 2016
SELinux frequently used info
Disable/enable on the fly Either turn it on:
sudo setenforce enforcing or turn it off:
sudo setenforce permissive These aren’t permanent changes; next reboot it’ll go back to whatever the config is set to. But this will let you on the fly turn on or off SELinux. I use it if I suspect SELinux to be blocking something.
Change context Sometimes one has to change context of a file or directory.
July 22, 2016
Default grub entry centos 7
/boot/grub2/grub.cfg has a list of menuentries with a lot of information in each. Starting at 0 count down to the one you want (you could script this out too). Then take that number and edit /etc/default/grub. In that file, add (or edit) a line:
GRUB_DEFAULT=x x being the number of the menuentry you picked from looking in /boot/grub2/grub.cfg
Then you have to update the grub.cfg file by running:
grub2-mkconfig -o /boot/grub2/grub.
July 21, 2016
Tuning dd block size
I wanted to write this down for my own reference. I’ve been dealing with dd a bit recently and the whole block size issue comes up. What is optimal? That depends on your hardware. This article here has a way to test and determine what the optimal block size is:
http://blog.tdg5.com/tuning-dd-block-size/
July 5, 2016
Foreground and background jobs
FG BG jobs nohup, disown, screen
Jobs What are Jobs? A job is a concept used by the shell – any program you interactively start that doesn’t detach (ie, not a daemon) is a **job. **Jobs can reside in the foreground (spitting output to the terminal) or in the background (they run, but you don’t get their output spat to the terminal).
One can send a job to BG right away using the ‘&’ at the end of the command.
July 5, 2016
Centos 7 firewall
Just a quick note, I had to open up a hole in the firewall on the server itself (even though I had my router stuff all set right already) by doing:
<i>sudo firewall-cmd --permanent --zone=public --add-port=80/tcp sudo firewall-cmd --reload </i> Worked great. I guess having a firewall on the server itself is good too. Instead of just relying on the one on the outer edge of the network.
July 5, 2016
Nvidia ethernet and centos 7
So I bought a simple dual core desktop machine recently to use as a simple server. I fired it up with centos 7’s “minimal” ISO. Got up and going, network didn’t work (lights were flashing, but nothing but a loopback device was recognized by the system). So I installed the “DVD” iso, hoping it would have whatever extra thing in it that was needed for the networking but still no dice.
June 27, 2016
stdin, stdout and stderr
Redirecting
stdin is a channel where one provides input (keyboard, typically)
stdout is a channel that a script or program uses to output information
stderr is another channel used by a script or program to output errors
< redirect stdin
redirect stdout
2> redirect stderr
Examples:
This redirects any errors to the ‘err’ file
ls nonexistentfile 2> err This redirects any actual output to the ‘out’ file and errors to ‘err’
June 16, 2016
Environment variables
The only thing I really need to know is that this command displays all of them from the current session:
env<del></del> But I guess I’ll write down some other stuff too.
The ‘export‘ command makes a variable available to any children of the current session. That’s the only real reason that it should be used. Otherwise you can prepend to the path for instance using:
PATH=/home/myself/bin/:$PATH You can unset variables using the ‘unset‘ command
June 14, 2016
ext4 inodes
Just needed to know recently how many inodes one can expect on a basic VPS server. According to ArchWiki:
mkfs.ext4 uses by default a rather low ratio of one inode every 16384 bytes (16 Kb) Which roughly boils down to 1M inodes per 15GB of space.
Tag: virtualization
September 24, 2016
What's CPU steal?
I heard about CPU steal recently. Had no idea what it was, so went looking. I’ll write here what I find.
Hypervisors – those are the softwares that “lie” to a guest OS in telling it what kinds of resources it has available (keyboard, mouse, ram, cpu, disk space, etc)
Class 1 hypervisor – a virtualization host that runs on the bare metal. It’s own OS, per se. Lightweight.
Class 2 hypervisor – a piece of software that runs in an OS, such as vmware or virtualbox
Tag: permissions
September 23, 2016
Umask
What in the heck is it? How does it work? The umask is a way to determine for a given user what the permissions of newly created files and directories have. Supposedly Linux wants 666 and 777 to be default perms for files and directories, respectively. Notice when you make a file, it’s set to 644, and directories to 755 though. That’s because this umask value is taking effect. On my machine anyway, the default umask is 022 (—-w–w-).
September 23, 2016
Permission quick reference
Because I always need to refer to this for some reason
4 - r 2 - w 1 - x Note: execute is required to change to a directory
4 - setuid 2 - setgid 1 - sticky
Tag: file types
September 20, 2016
File types in linux
Just a quick reference
Regular file (-) Directory (d) Symlink (l) Named pipe (p) Socket (s) Character device (c) Block device (b)
Tag: reference
September 20, 2016
File types in linux
Just a quick reference
Regular file (-) Directory (d) Symlink (l) Named pipe (p) Socket (s) Character device (c) Block device (b)
Tag: mysql
September 15, 2016
Show Character Set
I just learned about the ‘SHOW CHARACTER SET’ statement; it lists all of the available character sets and their default collations on a particular mySQL server. Handy if you just need to know which character sets/collations a server does or does not support.
The mySQL manual does say this though:
In cases where a character set has multiple collations, it might not be clear which collation is most suitable for a given application.
July 16, 2016
mysql_secure_installation
I just learned about ‘mysql_secure_installation’ which is a script that sets a root password for you and does some other cleanup/maintenance to the mysql server
Tag: owncloud
August 22, 2016
Owncloud's Documents app
I had heard at some point of an app that would allow one to edit .odt files in the browser, and apparently also .doc and .docx files (microsoft). I had to just download and unpack the app to the right location in my ownCloud instance, then install libreoffice (I prefer libre over open for some reason). One thing I didn’t know though was that I needed to install the “libreoffice-headless” package so it wouldn’t try to use the x server (nonexistent) on the machine.
Tag: selinux
August 22, 2016
SELinux frequently used info
Disable/enable on the fly Either turn it on:
sudo setenforce enforcing or turn it off:
sudo setenforce permissive These aren’t permanent changes; next reboot it’ll go back to whatever the config is set to. But this will let you on the fly turn on or off SELinux. I use it if I suspect SELinux to be blocking something.
Change context Sometimes one has to change context of a file or directory.
Tag: ebook
August 21, 2016
Upload PDFs to Google Books and preserve page numbers
When uploading to Google Docs, the PDF doesn’t make it through without getting beat up. My page numbers are missing, the table of contents is gone, etc. I heard that if one converts the PDF to ePub, the data is preserved. I know of a program called Calibre that allows one to convert PDF to ePub. This post suggested some commands:
ebook-convert file.pdf file.epub If the output looks a little wrong – try this
Tag: google books
August 21, 2016
Upload PDFs to Google Books and preserve page numbers
When uploading to Google Docs, the PDF doesn’t make it through without getting beat up. My page numbers are missing, the table of contents is gone, etc. I heard that if one converts the PDF to ePub, the data is preserved. I know of a program called Calibre that allows one to convert PDF to ePub. This post suggested some commands:
ebook-convert file.pdf file.epub If the output looks a little wrong – try this
Tag: pdf
August 21, 2016
Upload PDFs to Google Books and preserve page numbers
When uploading to Google Docs, the PDF doesn’t make it through without getting beat up. My page numbers are missing, the table of contents is gone, etc. I heard that if one converts the PDF to ePub, the data is preserved. I know of a program called Calibre that allows one to convert PDF to ePub. This post suggested some commands:
ebook-convert file.pdf file.epub If the output looks a little wrong – try this
Tag: php
August 11, 2016
PHP’s DateTime hates handling variables directly
I’m working on an app and found that this keeps failing saying “DateTime __construct() Failed to parse time string (xxxxxxxx) at position x”
Code was as follows:
$epoch = 1447258140; $dt = new DateTime($epoch); // This was the failing point $timestamp = $dt->format('Y-m-d H:i:s'); But I learned here: http://stackoverflow.com/questions/17427503/php-datetime-construct-failed-to-parse-time-string-xxxxxxxx-at-position-x
That it’s best to just create the DateTime, then use one of its methods to set the time:
$epoch = 1447258140; $dt = new DateTime(); $dt->setTimestamp($epoch); $timestamp = $dt->format('Y-m-d H:i:s'); That worked wonderfully!
Tag: grub
July 22, 2016
Default grub entry centos 7
/boot/grub2/grub.cfg has a list of menuentries with a lot of information in each. Starting at 0 count down to the one you want (you could script this out too). Then take that number and edit /etc/default/grub. In that file, add (or edit) a line:
GRUB_DEFAULT=x x being the number of the menuentry you picked from looking in /boot/grub2/grub.cfg
Then you have to update the grub.cfg file by running:
grub2-mkconfig -o /boot/grub2/grub.
June 8, 2016
Grub Legacy vs Grub 2
GRand Unified Boot System
Essentially, Grub Legacy is easy to reconfigure by just changing a single file. Grub 2 has several config files, then once you’ve changed them, you have to run a script to update the cfg file that grub2 reads in order for the changes to take effect.
Legacy config is simple: /boot/grub/menu.lst « how you change how the system boots, unique to grub legacy
Grub2 config: /etc/default/grub « one of the config files
Tag: dd
July 21, 2016
Tuning dd block size
I wanted to write this down for my own reference. I’ve been dealing with dd a bit recently and the whole block size issue comes up. What is optimal? That depends on your hardware. This article here has a way to test and determine what the optimal block size is:
http://blog.tdg5.com/tuning-dd-block-size/
June 24, 2016
Block devices, filesystems
dd – strictly works with block systems, not filesystems. It takes an input file (if), an output file(of) and block size as arguments. It copies everything block for block from one block device / file to another. That’s why you can use dd to create a bootable USB. it takes the if of an .iso and an of of /dev/sdb (a usb drive perhaps) and copies it straight over. Requires sudo in many cases because we’re dealing directly with devices (/dev/sd*).
Tag: nvidia
July 5, 2016
Nvidia ethernet and centos 7
So I bought a simple dual core desktop machine recently to use as a simple server. I fired it up with centos 7’s “minimal” ISO. Got up and going, network didn’t work (lights were flashing, but nothing but a loopback device was recognized by the system). So I installed the “DVD” iso, hoping it would have whatever extra thing in it that was needed for the networking but still no dice.
Tag: burn
July 4, 2016
growisofs
Found this cool tool to burn an ISO to CD or DVD with a quick command:
growisofs -Z /dev/dvdrw=<path to iso> An example:
growisofs -Z /dev/dvdrw=/home/riley/Downloads/CentOS-7-x86_64-Minimal-1511.iso
Tag: growisofs
July 4, 2016
growisofs
Found this cool tool to burn an ISO to CD or DVD with a quick command:
growisofs -Z /dev/dvdrw=<path to iso> An example:
growisofs -Z /dev/dvdrw=/home/riley/Downloads/CentOS-7-x86_64-Minimal-1511.iso
Tag: compression
June 27, 2016
compressing files
Supposedly bzip2 compresses more than gzip does (but uses more CPU to do so).
Tag: block device
June 24, 2016
Block devices, filesystems
dd – strictly works with block systems, not filesystems. It takes an input file (if), an output file(of) and block size as arguments. It copies everything block for block from one block device / file to another. That’s why you can use dd to create a bootable USB. it takes the if of an .iso and an of of /dev/sdb (a usb drive perhaps) and copies it straight over. Requires sudo in many cases because we’re dealing directly with devices (/dev/sd*).
Tag: cpio
June 24, 2016
Block devices, filesystems
dd – strictly works with block systems, not filesystems. It takes an input file (if), an output file(of) and block size as arguments. It copies everything block for block from one block device / file to another. That’s why you can use dd to create a bootable USB. it takes the if of an .iso and an of of /dev/sdb (a usb drive perhaps) and copies it straight over. Requires sudo in many cases because we’re dealing directly with devices (/dev/sd*).
Tag: filesystem
June 24, 2016
Block devices, filesystems
dd – strictly works with block systems, not filesystems. It takes an input file (if), an output file(of) and block size as arguments. It copies everything block for block from one block device / file to another. That’s why you can use dd to create a bootable USB. it takes the if of an .iso and an of of /dev/sdb (a usb drive perhaps) and copies it straight over. Requires sudo in many cases because we’re dealing directly with devices (/dev/sd*).
Tag: tar
June 24, 2016
Block devices, filesystems
dd – strictly works with block systems, not filesystems. It takes an input file (if), an output file(of) and block size as arguments. It copies everything block for block from one block device / file to another. That’s why you can use dd to create a bootable USB. it takes the if of an .iso and an of of /dev/sdb (a usb drive perhaps) and copies it straight over. Requires sudo in many cases because we’re dealing directly with devices (/dev/sd*).
Tag: text manipulation
June 17, 2016
Paste, join and expand text
A few new commands for manipulating text that I never knew about:
paste allows one to “paste” two files side by side. First row’s contents of fileB.txt will be to the left of the first row’s contents of fileA.txt, and on down the line. join Imagine mysql or something, this “joins” two (or maybe more) files together on a common field in whitespace-separated lines. It ignores unique values (at least by default) expand I don’t know what I’d ever use this for, but it will convert tabs into spaces.
Tag: conditional
June 16, 2016
BASH one-line if
I recently learned about this:
(( 1 )) && echo "true" || echo "false" Which is a great way to do an if statement on a single line, if you ask me. I could just do if [[ cond ]]; do something else; another thing; fi but I think this one is pretty slick.
[[ cond ]] && <what happens if true> || <what happens if false>
Tag: echo
June 14, 2016
Escaping characters in echo
I knew of this option:
echo -e "\042asdf\042" # this prints ("asdf") but never realized that one could also:
echo $'\042asdf\042' # this also prints ("asdf") I don’t even know what to call that…
Tag: escaping
June 14, 2016
Escaping characters in echo
I knew of this option:
echo -e "\042asdf\042" # this prints ("asdf") but never realized that one could also:
echo $'\042asdf\042' # this also prints ("asdf") I don’t even know what to call that…
Tag: ssh
June 13, 2016
SSH to virtualbox server
So I have been trying to figure this out. I am supposed to be able to do some port forwarding, which isn’t hard, but it wasn’t working. Eventually I went with the option of setting up two network adapters, one set up on NAT (so the VM can access the www) and another as a host-only, so the host can access the guest on 192.168.x.x
I was having a problem though, it was refusing me.
Tag: apt
June 10, 2016
APT
Sources lists found in:
/etc/apt/sources.list /etc/apt/sources.list.d/* Apt-get and apt-cache commands go hand-in-hand, whereas aptitude is new and kinda rolls them into one.
There’s a script called:
dpkg-reconfigure which can walk one through the initial setup of a package that they’d have found when they first installed a package.
Tag: libraries
June 9, 2016
Shared libraries in linux
Programs on a system need to use libraries of code. It makes sense to share those libraries because several programs might utilize the same library. That way it doesn’t require as much RAM and disk space to run 10 programs that it would if they didn’t share libraries.
ldd The above command allows me to find out what libraries that a particular program depends on. Such as:
$ ldd /bin/ls linux-vdso.
Tag: lvm
June 8, 2016
RAID vs LVM
RAID RAID (Redundant Array of Independent Disks) offers Performance and Reliability
Striped vs Mirrored – Striped has zero redundancy, but Mirrored is redundant.
Raid0 – striped. 4 drives in a raid0 at 20gb each provide 80gb total. High performance. You can write to all 4 drives at the same time (called striping). But it comes with a cost. Say that one HD goes down. Then the whole raid array fails because one file could be written across 4 drives, and if one drive goes down, the file is not usable.
Tag: raid
June 8, 2016
RAID vs LVM
RAID RAID (Redundant Array of Independent Disks) offers Performance and Reliability
Striped vs Mirrored – Striped has zero redundancy, but Mirrored is redundant.
Raid0 – striped. 4 drives in a raid0 at 20gb each provide 80gb total. High performance. You can write to all 4 drives at the same time (called striping). But it comes with a cost. Say that one HD goes down. Then the whole raid array fails because one file could be written across 4 drives, and if one drive goes down, the file is not usable.
Tag: shutdown
June 7, 2016
Shutdown
Shutdown does a few things:
shutdown -P #powers off the machine shutdown -r #reboots the thing shutdown -h #halts (but doesn't necessarily power off) the machine That’s fun!
Tag: sudo
June 7, 2016
sudo or wheel
I just found out that in some systems (looking at centOS 7 currently) have a ‘wheel’ group, which supposedly is the equivalent of the ‘sudo’ group on my Ubuntu install. Wheel is something old-school that stuck around. Meant “big wheel” which apparently was something like “big cheese”, which also doesn’t make sense but they mean “someone with power” or “in charge”.
Tag: wheel
June 7, 2016
sudo or wheel
I just found out that in some systems (looking at centOS 7 currently) have a ‘wheel’ group, which supposedly is the equivalent of the ‘sudo’ group on my Ubuntu install. Wheel is something old-school that stuck around. Meant “big wheel” which apparently was something like “big cheese”, which also doesn’t make sense but they mean “someone with power” or “in charge”.
Tag: cpanel
June 7, 2016
Force cPanel backups
Real simple:
/usr/local/cpanel/bin/backup --force Just that single command. So it IS possible. Everyone always tells me it isn’t… This force-runs the daily backup option. Mind you, it does so for ALL of the accounts listed in WHM.
One thing I noticed is it sticks the backup in /backup/ … Hmm…
Tag: init
June 6, 2016
systemd notes
Change target / mode:
systemctl isolate <target> Find default mode:
systemctl get-default Set a default mode:
systemctl set-default <target> Note the needs to end in “.target” ie:
systemctl set-default multi-user.target Locations:
/etc/systemd/system
/usr/lib/systemd/system
June 6, 2016
sysV notes
Change runlevel:
telinit 5 ‘5’ above being the runlevel you want to switch to.
Default runlevel specified in /etc/inittab:
<tt class="computeroutput">id:5:initdefault:</tt>
Tag: systemd
June 6, 2016
systemd notes
Change target / mode:
systemctl isolate <target> Find default mode:
systemctl get-default Set a default mode:
systemctl set-default <target> Note the needs to end in “.target” ie:
systemctl set-default multi-user.target Locations:
/etc/systemd/system
/usr/lib/systemd/system
Tag: sysv
June 6, 2016
sysV notes
Change runlevel:
telinit 5 ‘5’ above being the runlevel you want to switch to.
Default runlevel specified in /etc/inittab:
<tt class="computeroutput">id:5:initdefault:</tt>
Tag: api
May 25, 2016
Discord Bot
I had a bunch of problems getting a discord bot going. Here’s what I did:
Registered an app and set up a bot user. Sign into the gateway (only required once, but it won’t let your bot send messages otherwise). I ran this JS snippet in the console of Chrome: var ws = new WebSocket('wss://gateway.discord.gg'); mystring = JSON.stringify({ "op": 2, "d": { "token": "<bot token>", "properties": { "$os": "linux", "$browser": "sometestingbrowser", "$device": "sometestingdevice", "$referrer": "", "$referring_domain": "", }, "compress": true, "large_threshold": 250, } }) ws.
Tag: discord
May 25, 2016
Discord Bot
I had a bunch of problems getting a discord bot going. Here’s what I did:
Registered an app and set up a bot user. Sign into the gateway (only required once, but it won’t let your bot send messages otherwise). I ran this JS snippet in the console of Chrome: var ws = new WebSocket('wss://gateway.discord.gg'); mystring = JSON.stringify({ "op": 2, "d": { "token": "<bot token>", "properties": { "$os": "linux", "$browser": "sometestingbrowser", "$device": "sometestingdevice", "$referrer": "", "$referring_domain": "", }, "compress": true, "large_threshold": 250, } }) ws.
Tag: gateway
May 25, 2016
Discord Bot
I had a bunch of problems getting a discord bot going. Here’s what I did:
Registered an app and set up a bot user. Sign into the gateway (only required once, but it won’t let your bot send messages otherwise). I ran this JS snippet in the console of Chrome: var ws = new WebSocket('wss://gateway.discord.gg'); mystring = JSON.stringify({ "op": 2, "d": { "token": "<bot token>", "properties": { "$os": "linux", "$browser": "sometestingbrowser", "$device": "sometestingdevice", "$referrer": "", "$referring_domain": "", }, "compress": true, "large_threshold": 250, } }) ws.