# Generate a Private Key openssl genrsa -out privatekey.pem 2048 # Generate a self-signed certificate openssl req -new -x509 -key privatekey.pem -out self_signed_certificate.pem -days 365 # Convert PEM certificate to CER format openssl x509 -inform PEM -in self_signed_certificate.pem -outform DER -out self_signed_certificate.cer # Convert a PEM certificate to a PFX (PKCS#12) file openssl pkcs12 -export -out certificate.pfx -inkey privatekey.pem -in self_signed_certificate.pem # Extract a private key from a PFX file (contain bag attributes) # openssl pkcs12 -in certificate.pfx -nocerts -nodes -out privatekey_frompfx.pem openssl pkcs12 -in certificate.pfx -nocerts -nodes -out privatekey_frompfx.key # Extract a private key (no bag attributes) - identical to privatekey.pem openssl rsa -in privatekey_frompfx.key -out privatekey_frompfx.key # Extract public key from key pair openssl rsa -in privatekey_frompfx.key -pubout -out publickey.key #openssl rsa -in privatekey.pem -pubout -out publickey2.key # Convert CER to CRT openssl x509 -inform DER -in self_signed_certificate.cer -out self_signed_certificate.crt #openssl x509 -inform PEM -in self_signed_certificate.cer -out self_signed_certificate.crt # Convert CRT to CER openssl x509 -in self_signed_certificate.crt -outform DER -out self_signed_certificate2.cer ##### # Generate a Certificate Signing Request (CSR) - optional if going to generate a self-signed #openssl req -new -key privatekey.pem -out certificate_request.csr #openssl x509 -req -in certificate_request.csr -signkey privatekey.pem -out self_signed_certificate3.crt
Computer, Technology, Databases, Google, Internet, Mobile, Linux, Microsoft, Open Source, Security, Social Media, Web Development, Business, Finance
Search This Blog
Google Analytics
Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts
Wednesday, April 10, 2024
Useful openssl commands to generate certificates and keys
I hope the following will come handy when it comes to generating key pairs and certificates.
Friday, April 18, 2014
Cheat Sheet - Learn Basic Linux Commands
A cheat sheet on Linux commands, organised into 13 categories, should get you up to mark in using Linux operating system. The cheat sheet is available at LinOxide in PDF format and as one detailed reference guide all on a single long page. If you prefer visual, the following image may be helpful too.
Saturday, March 09, 2013
Linux Cheat Sheet (Command Lines)
# cheat_sheet.org.sh
# (C) William Hackmore, 2010
# The contents of this file are released under the GNU General Public License. Feel free to reuse the contents of this work, as long as the resultant works give proper attribution and are made publicly available under the GNU General Public License.
# Best viewed in emacs org-mode.
* Reference:
** Basics:
*** Getting help:
# View the manual for target command
man command
# Get help with a target command (probably the same as above, but not always):
command -h
# In case you forget the name of a command, print possible commands relating to guess:
apropos guess
# View index of help pages:
info
*** Command Line Utilities:
**** Basic File and Directory Operations:
# Print current working directory:
pwd
# Show files in current directory:
ls
# Show maximum information about all files, including hidden:
ls -a
# Recurse into subdirectories and list those as well:
ls -R
# Move/rename a file or directory (be careful that you don't move the source over a destination with the same name):
mv source destination
# Delete target forever (be very careful), use -r recursive flag for directories:
rm target
# Copy file or directory:
cp source destination
# Mount filesytem:
mount /dev/device_name /media/device_name
# Unmount:
umount /media/device name
# Forensically clone filesystems and do other low-level operations on files. Be careful with this one. Can be destructive:
dd
# Work with filesystems and partitions. (Easier, still quite dangerous):
fdisk
**** System Administration:
# Execute command as an administrator (can be destructive/insecure. Use only for system administration tasks):
sudo command
# Become system administrator:
sudo -s
# Quit system administration:
exit
***** Installing software from a .tgz (also known as a tarball):
# First, unzip the tarball (see section on tar, below)
# Next, move into unzipped directory:
cd software_directory
# Always read README first if it is provided, in case there are any modifications to the procedure outlined below:
cat README
# Automatically check for appropriate configurations and generate a MAKE file in the directory:
./configure
# Compile software. May require sudo:
make
# Move files into their appropriate locations. May also require sudo:
make install
# Clean up files in directory, in case make command fails, or just to remove unnecessary cruft:
make clean
***** Ubuntu/Debian Software repositories:
# Check distro repositories for software updates:
sudo apt-get update
# Download and install updates (update first):
sudo apt-get upgrade
# Search for package in the repositories:
apt-cache search keyword
# Get more detail on one specific package:
apt-cache show package_name
# Download and install a package:
sudo apt-get install package_name
# View the output of a command in a more convenient format:
command | less
**** Working With Files:
# Print a file in terminal:
cat file
# Find files matching filename:
locate filename
# Search through filename for matches to phrase:
grep phrase filename
# Search through output of a command for phrase:
command | grep phrase
**** Working With Processes:
# List all running processes:
ps -e
# Standard system monitor showing a more extensive view of all processes and system resources:
top
# Like top, but with a better, cleaner interface:
htop
# Stop a process from using all system resources and lagging computer:
nice process_name
# Kill misbehaving process (use sparingly, last resort, try 'nice' command first):
pkill process name
# Start a process in the background
command &
# Start a process in the background and have it keep running after you log off
nohup command &
**** Compression and Encryption:
# Make a simple compressed backup of a file or directory:
tar -cvzf backup_output.tgz target_file_or_directory
# Open a compressed .tgz or .tar.gz file:
tar -xvf target.tgz
# Encrypt a file:
gpg -o outputfilename.gpg -c target_file
# Decrypt a file:
gpg -o outputfilename -d target.gpg
# Zip and encrypt a directory simultaneously:
gpg-zip -o encrypted_filename.tgz.gpg -c -s file_to_be_encrypted
*** The Bash shell:
**** File Name expansions:
# Current user's home directory:
~/
# Current directory:
./
# Parent directory:
../
# Or even (Two parent directories down):
../../
# All files in target directory. (Be very careful.):
/*
**** Output Redirects:
# Redirect output of one command into the input of another with a pipe:
command_1 | command_2
# Or even:
command_1 | command_2 | command_3
# Redirect output to a file:
command > file
# Or:
file > file
# Or even, to redirect in a different direction:
file < file
# Append output rather than writing over the target file:
file_or_command >> file
# Works like |, but it writes output to both target and terminal:
tee target
# Redirect standard output and error to /dev/null, where it is deleted.
command > /dev/null 2>&1
**** Controlling Execution:
# Wait until command 1 is finished to execute command 2
command_1 ; command_2
# Or even:
command_1 ; command_2 ; command_3
# && acts like ; but only executes command_2 if command_1 indicates that it succeeded without error by returning 0.
command_1 && command_2
# || acts like && but only executes command_2 if command_1 indicates an error by returning 1.
command_1 || command_2
**** Bash Wildcards:
# Zero or more characters:
*
# Matches "phrase" and any number of trailing characters:
phrase*
# Matches any incidences of "phrase" with any trailing or leading chars:
*phrase*
# Matches any one char:
?
# Matches any of the characters listed inside brackets:
[chars]
# Matches a range of chars between a-z:
[a-z]
** Advanced:
*** Command Line Utilities, Continued:
**** Networking:
# Configure network interfaces:
ifconfig
# Configure wireless network interfaces:
iwconfig
# Connect to a remote server.
ssh username@ip_address
# Forward X from target to current machine (Get a remote desktop. Somewhat obscure, but very useful):
ssh -X username@ip_address
# Copy files over the network from one machine to another:
scp source_filename:username@ip_address target_filename:target_username@target_ip_address
# Copy only changes between files or directories (super efficient way to sync directories, works either locally or with remote servers using username@ip_address:optionalport, just like ssh):
rsync source target
# Check to see if target is online and responding
ping ip_address
# View network route to target:
traceroute6 ip_address
# Network Monitor
netstat
# Manage standard linux firewall (advanced users only)
iptables
# Scan this machine to check for open ports:
nmap 127.0.0.1
***** netcat:
# Listen for input from network on recieving_port, dump it to a file (insecure, but handy):
netcat -l recieving_port > file_copied
# Pipe the output of a command to a target ip and port over the network:
command | netcat -w number_of_seconds_before_timeout target_ip target_port
# Use tar to compress and output a file as a stream, pipe it to a target ip and port over the network:
sudo tar -czf - filename | netcat -w number_of_seconds_before_timeout target_ip target_port
**** Users and Groups:
# Change owner of a file or directory:
chown user_name:group_name directory_name
# Change privileges over file or directory (see man page for details.)
chmod
# Create a new user:
adduser
# Change user privileges (be very careful with this one):
usermod
# Delete user
deluser
# Print groups:
groups
# Create a new group:
groupadd
# Change group privileges:
groupmod
# Delete group:
delgroup
# Temporarily become a different user:
su username
# Print usernames of logged in users:
users
# Write one line to another user from your terminal:
talk
# Interactive talk program to talk to other users from terminal (must be installed from repositories.):
ytalk
**** Working With Files, Continued:
# View what processes are using what files:
lsof
# View the differences between two files:
diff file_1 file_2
# Output the top number_of_lines of file:
head -n number_of_lines file
# Like head, but it outputs the last -n lines:
tail -n number_of_lines file
# Checksum a file:
md5sum file
# Checksum every file in a directory (install this one from repositories.):
md5deep directory
# Checksum a file (better algorithm with no hash collisions):
sha1sum
# Same operation as md5deep, but using sha1:
sha1deep
# Call command every few number_of_seconds, and display output:
watch -n number_of_seconds command
# Execute command, print how long it took:
time command
# View files in directory from largest to smallest:
du -a directory | sort -n -r | less
# remove spaces from filenames in current directory:
rename -n 's/[\s]/''/g' *
# change capitals to lowercase in filenames in current directory:
rename 'y/A-Z/a-z/' *
***** Environment and Hardware:
# Print full date and time:
date
# Print the hostname of this machine:
echo $HOSTNAME
# Print information about current linux distro:
lsb_release -a
# Print linux kernel version:
uname -a
# Print information about kernel modules:
lsmod
# Configure kernel modules (never do this ;p ):
modprobe
# View Installed packages:
dpkg --get-selections
# Print environment variables:
printenv
# List hardware connected via PCI ports:
lspci
# List hardware connected via USB ports:
lsusb
# Print hardware info stored in BIOS:
sudo dmidecode
# Dump captured data off of wireless card:
dumpcap
# Dump info about keyboard drivers:
dumpkeys
***** Ubuntu System Administration, Advanced (Continued):
# Add a Personal Package Archive from Ubuntu Launchpad:
add-apt-repository
# Install a .deb file from command line:
sudo dpkg -i package.deb
**** Python:
# Update pip (Python package manager):
pip install -U pip
# search pip repos for a library:
pip search library_name
# create a virtual ython environment to allow install of many different versions of the same Python modules:
virtualenv dirname --no-site-packages
# connect to a virtual python environment
source dirname/bin/activate
# disconnect from a virtual python environment:
deactivate
# install package into virtual python environment from outside:
pip install packagename==version_number -E dirname
# export python virtual environment into a shareable format:
pip freeze -E dirname > requirements.txt
# import python virtual environment from a requirements.txt file:
pip install -E dirname -r requirements.txt
**** git (all commands must be performed in the same directory as .git folder):
# Start a new git project:
git init
git config user.name "user_name"
git config user.email "email"
# Make a copy of a git (target can be specified either locally or remotely, via any number of protocols):
git clone target
# Commit changes to a git:
git commit -m "message"
# Get info on current repository:
git status
# Show change log for current repository:
git log
# Update git directory from another repository:
git pull [target]
# Push branch to other repository:
git push [target]
# Create a new branch:
git branch [branchname]
# Switch to target branch:
git checkout [branchname]
# Delete a branch:
git branch -d [branchname]
# Merge two branches:
git merge [branchname] [branchname]
# Show all branches of a project:
git show-branch
*** Virtualization:
#clone a virtual machine (this works, it's been tested):
vboxmanage clonehd virtual_machine_name.vdi --format VDI ~/target_virtual_machine_name.vdi
#mount a shared virtual folder:
#you need to make sure you have the right kernel modules. You can do this with modprobe, but this package works instead in a ubuntu-specific way.
sudo apt-get install virtualbox-ose-guest-utils
sudo mount -t vboxsf name_of_shared_folder_specified_in_Virtualbox path_of_mountpoint
*** mysql:
# Get help:
help
# Show databases:
show databases;
# Choose a database to use:
use database_name_here;
# Show database schema:
show tables;
# Delete database:
DROP DATABASE databasename;
# New database:
CREATE DATABASE databasename;
# Create a new user:
CREATE USER username@localhost IDENTIFIED BY 'password';
# Show users:
select * from mysql.user;
# Delete a user:
delete from mysql.user WHERE User='user_name';
# Give user access to all tables (make them root). the "%" means that they can sign in remotely, from any machine, not just localhost.:
grant all privileges on *.* to someusr@"%" identified by 'password';
# give certain privileges to a user on a certain database:
grant select,insert,update,delete,create,drop on somedb.* to someusr@"%" identified by 'password';
# Tell mysql to use new user priv policies:
flush privileges;
# change user password:
use mysql;
update user set password='password'('newpassword') where User='user_name';
# mysql command line args:
# export text file with commands to rebuild all mysql tables:
mysqldump databasename > dumpfilename.txt
# restore from a dump:
mysql -u username -p < dumpfilename.txt
# dump entire database:
mysqldump -u username -p --opt databasename > dumpfile.sql
# restore from entire database dump:
mysql -u username -p --database=databasename < dumpfile.sqlCourtesy of a GitHub user here
Monday, January 23, 2012
How to extract tar ball (tar.gz, tgz) using command line?
If you have a tgz or a tar.gz archive, you may use the following to extract its files using command line interface.
Extract to current directory.
Extract to a different target directory.
Extract to current directory.
tar -zxf yourtarball.tgz
Extract to a different target directory.
tar -C ~/owndirectory -zxf yourtarball.tgz
Sunday, January 22, 2012
sudo apt-get commands
From the Ubuntu documentation,
Update the Package Index - Run this command periodically to make sure your source list is up-to-date.
Upgrade Packages - This command upgrades all installed packages.
Upgrade Packages with "smart upgrade" - The same as the above, except add the "smart upgrade" checkbox.
Install a Package
Remove a Package
The apt-get command is a powerful command-line tool used to work with Ubuntu's Advanced Packaging Tool (APT) performing such functions as installation of new software packages, upgrade of existing software packages, updating of the package list index, and even upgrading the entire Ubuntu system.
Update the Package Index - Run this command periodically to make sure your source list is up-to-date.
sudo apt-get update
Upgrade Packages - This command upgrades all installed packages.
sudo apt-get upgrade
Upgrade Packages with "smart upgrade" - The same as the above, except add the "smart upgrade" checkbox.
sudo apt-get dist-upgrade
Install a Package
sudo apt-get install <app name>
Remove a Package
sudo apt-get remove <app name>
Wednesday, December 21, 2011
Make Ubuntu 11.10 Look and Feel Like GNOME 2
An interesting article on how to make your Ubuntu 11.10 user interface to be more GNOME 2.
Sunday, May 08, 2011
Wednesday, June 02, 2010
Are Mac OS X or Linux more secure than Windows?
As Google begins ditching Microsoft Windows in preference to Mac OS X and Linux citing security concerns after this January's Chinese Aurora attacks, question lies in if the alternative operating systems are really more secure.
As many are aware of Windows' security flaws, our perception is that Microsoft's operating system should be more insecure. Is that really true? The following article is an interesting read.
Mac OS X and Linux are no magic security bullet for Google [via]
As many are aware of Windows' security flaws, our perception is that Microsoft's operating system should be more insecure. Is that really true? The following article is an interesting read.
Mac OS X and Linux are no magic security bullet for Google [via]
Thursday, April 30, 2009
Login to Windows Administrator and Linux Root Account Without Knowing or Changing Current Password
Looks cool. Shall try it one day after my exams.
Login to Windows Administrator and Linux Root Account Without Knowing or Changing Current Password [via]
Login to Windows Administrator and Linux Root Account Without Knowing or Changing Current Password [via]
Tuesday, January 27, 2009
Windows 7.0 Final Nail in the Desktop Linux Market’s Coffin?
Below article discusses if the new upcoming Microsoft's operating Windows 7.0 is going to be a final nail in the desktop Linux market's coffin.
I am a Microsoft supporter.
Linux keeps dying [via]
I am a Microsoft supporter.
Linux keeps dying [via]
Thursday, May 08, 2008
Saturday, March 15, 2008
Monday, December 17, 2007
Linux Reader for Windows
How to get safe and quick access to alternative file systems? DiskInternals Linux Reader is a new easy way to do this. This program plays the role of a bridge between your Windows and Ext2/Ext3 Linux file systems. This easy-to-use tool runs under Windows and allows you to browse Ext2/Ext3 Linux file systems and extract files from there.
http://www.diskinternals.com/linux-reader/
http://www.diskinternals.com/linux-reader/
Saturday, July 07, 2007
Linux Considering Moving From VI/EMACS to Eclipse
I thought this is a great decision. VI, VIM or EMACS have been the standard for decades when it comes to doing programming on Linux.
Saturday, June 23, 2007
Ms Vista More Secure Than Linux / Mac
News Analysis: Windows Vista only had 12 vulnerabilities in its first six months, making Linux distros look buggy by comparison, but analysts aren't convinced.
Read for yourself.
http://www.eweek.com/article2/0,1759,2149391,00.asp
http://blogs.csoonline.com/windows_vista_6_month_vulnerability_report
Read for yourself.
http://www.eweek.com/article2/0,1759,2149391,00.asp
http://blogs.csoonline.com/windows_vista_6_month_vulnerability_report
Saturday, June 09, 2007
Microsoft Hires Former Linux Engineering Director
Microsoft has quietly hired Tom Hanrahan, formerly the Linux Foundation's director of engineering, to become its Director of Linux Interoperability. As part of his responsibilities, Hanrahan will manage the Microsoft/Novell Interoperability Lab that Microsoft began staffing up earlier this year.
Saturday, June 02, 2007
What is LAMP?
Often we get to hear people talking on LAMP. And so what exactly is LAMP?
It is not the LAMP we use at home. LAMP is an open source Web development platform based on Linux, Apache, MySQL, and PHP, a programming language for which Perl or Python is sometimes substituted.
It is not the LAMP we use at home. LAMP is an open source Web development platform based on Linux, Apache, MySQL, and PHP, a programming language for which Perl or Python is sometimes substituted.
Thursday, May 31, 2007
Linux & Star Office 8 on Singapore Airlines Planes
Can you imagine working on your word documents on a plane? Singapore Airlines (SIA) is providing this service to passengers. This means more time to do your documents and this means no excuse of not meeting deadlines!
http://www.eweek.com/article2/0,1759,2138618,00.asp?kc=EWRSS03119TX1K0000594
http://blogs.sun.com/chhandomay/entry/staroffice_8_in_singapore_airlines (With photo as proof)
http://www.eweek.com/article2/0,1759,2138618,00.asp?kc=EWRSS03119TX1K0000594
http://blogs.sun.com/chhandomay/entry/staroffice_8_in_singapore_airlines (With photo as proof)
Wednesday, May 23, 2007
PHP: Create Directory, Safe Mode Headache, etc
Many times when creating directories via script on a Linux/Unix machine can result in permission problems. Below will make sure it work provided FTP username and password provided is a user id with higher rights.
It does this:
Speed is a little slower then I wanted. But when dir allready exists there is no real speed difference. So I 'solved' the speed problem by creating the dirs when I know they will be needed in the future, rather than creating them at the moment I need them.
function site_mkdir($dir)
{
if (is_dir($_SERVER['DOCUMENT_ROOT'] . '/' . $dir))
{
return(true);
}
if (!$ftp_connection = ftp_connect('ftp.server'))
{
return(false);
}
if (!ftp_login($ftp_connection, 'user', 'password'))
{
return(false);
}
if (!ftp_chdir($ftp_connection, 'httpdocs'))
{
return(false);
}
$dir_list = explode('/', $dir);
foreach ($dir_list as $current)
{
if ($current != '')
{
if (!@ftp_chdir($ftp_connection, $current))
{
if (!ftp_mkdir($ftp_connection, $current))
{
ftp_close($ftp_connection);
return(false);
}
else
{
ftp_site($ftp_connection, 'CHMOD 0777 '.$current);
ftp_chdir($ftp_connection, $current);
}
}
}
}
ftp_close($ftp_connection);
return(true);
}It does this:
- check if the dir to create already exists; if it does, simply quit, otherwise continue
- login to my ftp server (same server as the script is running on)
- change to the base dir ($dir will use this as a base reference)
- split up $dir and walk through the list
- check if dir exists
- if not, create it
- if not, chmod it to 0777
- if exists, just continue
- closes connection
Speed is a little slower then I wanted. But when dir allready exists there is no real speed difference. So I 'solved' the speed problem by creating the dirs when I know they will be needed in the future, rather than creating them at the moment I need them.
Tuesday, May 22, 2007
Dell With Ubuntu Again?
This article says Dell may pack with Ubuntu.
http://www.pcmag.com/article2/0,1759,2134337,00.asp?kc=PCRSS03069TX1K0001121
However, an earlier article said no.
http://www.eweek.com/article2/0,1759,2126692,00.asp?kc=EWRSS03119TX1K0000594
http://www.pcmag.com/article2/0,1759,2134337,00.asp?kc=PCRSS03069TX1K0001121
However, an earlier article said no.
http://www.eweek.com/article2/0,1759,2126692,00.asp?kc=EWRSS03119TX1K0000594
Subscribe to:
Posts (Atom)
Popular Posts
-
新加坡人口400万,亚洲人口4亿,全世界人口6亿。 但是,我一人可能就很有可能是世界最傻的了。我真是个不折不扣的大木头。真是受不了自己。
-
If you live in the North-East and commute early, your daily transit routine just got a whole lot sweeter. The Land Transport Authority (LTA)...
-
Google url shortener service, goo.gl , is now much improved with newly included features like easier copy and paste, and ability to delete e...
-
Let’s be honest - Singapore isn't short on places to check the haze or PSI. Between official portals and various weather apps, the data ...
-
Just yesterday, popular food blogger, Brad Lau, who owns food blog ladyironchef , who had refused to pay the full cost of his 4-persons meal...
