validationRegex to accept/validate listed characters

5 to 16 alpha or alphanumeric to include special characters such as:
◦*Hyphen ( – )
◦*Slash ( / )
◦*Backslash ( )
◦*Asterisk ( * )
◦*Dollar Sign ( $ )
◦*Period ( . )
◦*Ampersand ( & )
◦*Comma ( , )
◦*Number Sign ( # )
◦*Open Parenthesis ( ( )
◦*Closed Parenthesis ( ) )
◦*Colon ( : )

Current code example:

PASSWORD: {id: password, label: PASSWORD, name: PASSWORD, validationRegex: ^[a-zA-Z0-9]+$, minLength: 5, maxLength: 16, errorMsg: message}

Go to Source
Author: Marcus

ANSWER

This regular expressions pattern should work to validate that the string is between 5 to 16 characters long, and has alphanumeric only with the special symbols allowed. Escaping those symbols so it is interpreted by regex compiler as a literal.

^([a-zA-Z0-9!-\?\\/.\,\$*\&\:()]{5,16})$

Results for the following samples of strings that pass the pattern and failed.

Passed

  • thequickbrownfox
  • !hello-world?
  • /hi\/there\
  • two
  • ast*risk*
  • $dollar$sign
  • 192.168.0.1
  • hello,world
  • (xx&:xx)
  • hashtag#allowed
  • 1234567890123456

Failed

Falls short of 5 characters or over 16 characters, does not have those special characters in the pattern, and with spaces or other whitespace characters.

  • abc1
  • this%not@allowed
  • iamoversixteencharacterslong
  • spaces not allowed
  • 12345678901234567

How can I install more than one Desktop Environment in my Ubuntu without damaging the system?

How can I install more than one Desktop Environment in my Ubuntu without damaging the system? I want just to try those desktop. I know I can install them by sudo apt install kubuntu/xubuntu/lubuntu-desktop . But it will remove my existing Desktop Environment, right? I want that whenever I want to change the Desktop Environment, I will log out and log in to that. Is it possible to do that? Don’t say to download ISO image of Kubuntu, Xubuntu, Lubuntu as I want to see them in my current installation.

Go to Source
Author: Akib Azmain

ANSWER

The recommended answer to installing another desktop environment on Ubuntu is to do as you mentioned using the package that ends in *-desktop. The * being the name of that DE. It should not remove or damage your existing DE. This can be done via terminal using apt command, or through the Ubuntu Software Center (or whatever it is called on the current version you’re on) GUI app.

Make sure you are installing from the official Ubuntu repositories to avoid conflicts or issues. Third party sources may cause unintended results so be wary. Also, read any warnings carefully before proceeding with the installation.

Once installed, logout of the current session. At the login screen, choose the DE that you want to use next.

Another way to try different DEs (or even Linux distros) is through a virtual machine. I always prefer this method since it’s clean, safe and quite easy to remove/manage. Use VMware, VirtualBox or whatever other option you prefer. Reuse that ISO you haveof your installed Ubuntu so you don’t have to re-download. You can also try things there first before doing it on your main desktop if you’re not sure what will happen and you’re not confident that you can restore it. The experience can almost be the same as if it were not running on VM (Make sure it’s running in full desktop mode). I’ve tried this approach several times whenever I plan to shift to another DE/distro but not sure how I will like it. So I use it for a number of days to immerse myself in that DE fully.

Need help with .htaccess redirection for WordPress websites

I am changing the domain of my website.

But, I am struggling with the domain redirection. I need to implement this wildcard redirection.

So that I visit.

https://www.oldomain.com/page1

It should go to

https://newdomain.com/page1

Note: The new domain is without www.

Can anyone help me how to implement this?

Go to Source
Author: Nirmal Kumar

ANSWER

A 301 Redirect, or permanent redirect, is recommended when dealing with something similar to this one.

If you just want to hard redirect anything hitting oldomain.com to newdomain.com then a simple Redirect should do like so:

<VirtualHost *:443>
	ServerName oldomain.com
        ServerAlias www.oldomain.com
	Redirect 301 / https://newdomain.com
</VirtualHost>

The above example is also something that you will want to write in a server config like httpd.conf but not in a .htaccess file somewhere on your site directory. It is also clumsy since your old site’s pages – e.g https://www.domain.com/some/page/123 – will redirect only to https://newdomain.com which is the index page of the site.

So the other option would be Rewrite. It is also in case you don’t have root access to the server, and/or other sites that are not yours are sharing it as well. It would look like the following:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^oldomain.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.oldomain.com [NC]
RewriteRule ^(.*)$ http://newdomain.com/$1 [L,R=301,NC]

The above considers whether the request is written with or without the www subdomain in it. The old links or pages will also get carried over to the new one.

How is a source RPM different from unpacking an RPM with rpm2cpio and cpio?

I am attempting to understand the use of a .srpm aka “source rpm” Red Hat Package Manager package. From what I understand so far, a .srpm is different from a standard .rpm in that it provides the source code and is commonly used during development. I am puzzled on why this is useful because if I run rpm2cpio ./myrpm-1.1-1.x86_64.rpm | cpio -idmv, I can still view the source code. As I understand, even standard RPMs pull down a .tar.gz/bz file which contains the source, and eventually builds this. Could you please clarify how source RPMs are different and why I would want to use one?

Go to Source
Author: the_endian

ANSWER

As I remember RPM files that end with extensions of .srpm or .src.rpm (I see this more often if I recall correctly) are copies of software source code including the build/compile scripts and instructions. Normally these are archived in tar format, before then being packaged further as RPM.

Because it is packaged as RPM, source RPMs can very well be installed the same way as any other RPM. The source files will go to a default folder on your Linux.

So there is the RPM mostly and mainly for binary or compiled software. Then the Source RPM that contains the source code of that software. These were distinctly packaged with the proper file extensions. Rightfully so people don’t get confused. Perhaps some RPM packagers also include the software’s source code in RPM, but I have not seen that yet.

On a side not, back in the days I used to build RPMs for myself a lot. It became sort of a hobby. This was circa 2006-2009.

There were a few reasons I did this.

  • Software I want to install on my Linux doesn’t have RPM, only tarballs.
  • I could install software via – .configure + make + make install – terminal kung fu, but it’s easier to track and manage via RPM.
  • Lastly. For fun, and wanted to think I’m cool. (j/k) On a serious note, for learning purposes.

My memory is a bit foggy on this now. But there was this really cool GUI utility tool that created RPMs for you. I just forgot the name of this little app. You just needed to supply it a copy of the tarball, some other info, then press the button. Magic. This was after I got tired doing it by hand on the Linux terminal, and as soon as I found out about this handy GUI tool, I mostly did it this way.

how to get specific character from a log file in linux

ANSWER

Assuming that (1) the log file looks as it is AND (2) it is multi-line, then a simple Linux grep command like below should work (even with multiple lines of that line you’re looking for in one log file):

INPUT | Tested it on dummy logs from sample

COMMAND | grep -Pn "^Id\s+:\s+(.*)$" *.log

OUTPUT |

log101.log:2:Id : UN123P

log102.log:2:Id : HELLO321

log103.log:2:Id : STUDE23P

log104.log:2:Id : Lorem

log104.log:7:Id : IPsum

log104.log:12:Id : Dolor

have a log file , having multiple contents inside the file like and example below is the content of U123.log . I have n number of logs..

Accepted password for hoover from 10.0.2.2 port 4792 ss

Id : UN123P 

ID_MTCH : UnixProduction

Accepted password for hoover from 10.0.2.2 port 4792 ss

Accepted password for hoover from 10.0.2.2 port 4792 ss

Is there any we can fetch “Id : UN123P” as an output of linux command. We have some 1000’s of logs and from all the logs , trying to fetch the value only starts with ID : and output as “Id : UN123P”

Pls suggest

Go to Source
Author: Arya