Make Offline Mirror of a Site Using `wget`

Use  wget to make an offline mirror of a website

wget --mirror --convert-links --adjust-extension --page-requisites 
--no-parent http://example.org
Explanation of the various flags:
  • --mirror – Makes (among other things) the download recursive.
  • --convert-links – convert all the links (also to stuff like CSS stylesheets) to relative, so it will be suitable for offline viewing.
  • --adjust-extension – Adds suitable extensions to filenames (html or css) depending on their content-type.
  • --page-requisites – Download things like CSS style-sheets and images required to properly display the page offline.
  • --no-parent – When recursing do not ascend to the parent directory. It useful for restricting the download to only a portion of the site.
Alternatively, the command above may be shortened:
wget -mkEpnp http://example.org
Note: that the last p is part of np (--no-parent) and hence you see p twice in the flags.

Configuring KDE to Have Desktop Icons Appear

On the desktop, select "Activities" (either on the menu bar at the bottom of the screen, or on the upper right corner box). Select "+ Create Activity" -> "Templates" -> "Desktop Icons". This selects the new activity "Desktop Icons"; this makes a new icon to appear "Desktop Icon"; when selected, will have the desktop icons appear and when "Desktop" activity is selected, the default desktop with a panel showing the Desktop folder appear.

Steam on Fedora 20

RPM packages are available from RPMFusion for all supported Fedora releases. The package works fine on both i686 and x86_64 systems and already contains support for the S3 Texture compression library for open source drivers (radeon, intel and nouveau) along with all the required libraries to start playing with Steam games. To install, after enabling the RPMFusion repositories, simply issue
sudo yum install steam
Note: There is also a staging repository where additional options are added to the package, like Valve's xpad driver and packages for running the SteamOS client in SteamOS mode. These features might not end up in RPMFusion. The repository is available at negativo17.org.
Source: Valve

Install .deb on Fedora 20

To install a debian package, you first need to convert it from a .deb package to a .rpm package (you may need to install alien first via sudo yum install alien which installs a bunch of perl modules...)
 >$ alien -r package.deb 

Then do the standard yum install:
 >$ sudo yum localinstall package.rpm

Moka Themes and Icons on Fedora 20

The Moka themes that are installed by default via fedy are obsolete.  The current Moka project repositories can be found at http://mokaproject.com/ .

First, install the repository:
su -c "yum-config-manager --add-repo http://mokaproject.com/packages/rpm/moka-stable.repo"
Then you can install the individual parts.
  • faba-icon-theme
  • faba-mono-icons
  • (these are supplemental icons)
  • moka-icon-theme
  • moka-gnome-shell-theme
  • orchis-gtk-theme
  • (requires the Murrine, but it is likely installed: yum search gtk-murrine-engine)
  • moka-cinnamon-theme
  • (!) Update! I don't need moka-cinnamon-theme because Fedora 20 uses gnome-shell - cinnamon is a fork of gnome-shell. Don't bother with this one!
    (!) Warning! I got "No package moka-cinnamon-theme available" when I tried to install this. And indeed, when I went and browsed the repo - I didn't see it under (http://mokaproject.com/packages/rpm/). But, one can download a package (.zip) and install it that way; see note below.

Instal an individual component like so:
su -c "yum install moka-icon-theme"

Notes:


  • Faba's purpose is to serve as a base icon theme to others (such as Moka). It comprises only of a system icons –folders, mimetypes, toolbar icons, etc. To fully experience Moka, it is recommended that you also install Faba Icon Theme.
  • The method shown here is Fedora 20 distribution specific. There are agnostic methods for installation.
  • UPDATE! Don't bother with moka-cinnamon-theme!
    For reference though, I've kept my notes below.
    Because the "preferred" method of downloading the archive doesn't work, I've downloaded the package (moka-cinnamon-theme.zip) and then installed it manually. One can run it as a user and have the theme installed in ~/.themes or as root (so all users can have access to the theme) and it will be installed in /usr/local/share/themes.
    Then you may select "Moka" in the Cinnamon theme preferences, or use the following command:
    gsettings set org.cinnamon.theme name "Moka"
    (BTW, it didn't work because I'm not using cinnamon, and it isn't installed! )
  • To enable the Moka Gnome Shell Theme, I believe you first need to use "Gnome Tweak Tool" to enable User Themes", and then the Moka Gnome Shell Theme can be selected. See here.

Fedora 20 - uses GNOME-Shell

FYI - Fedora 20 uses GNOME-Shell, not Cinnamon (as I thought earlier)! Cinnamon is a fork of GNOME-Shell and might be used by Mint Linux?

Windows Desktop Icons - Auto Arrange

Problem: the desktop icons don't move (you can't drag and move the icons).
Solution: right click the desktop,  click “View”, uncheck “Auto arrange icons”. 

Python and Command-Line Arguments

Use sys.argv and getopt . Sources: (here) (here too) (also here)

Ensuring new files in a directory belong to the group

Issue: I want to create a shared directory when a number of users (all belong to a group called mygroup) can create and edit files. I would like all files, including new files created in this directory and subdirectories to belong to the mygroup.

Solution: Set the SetGID sticky bit
$> chmod g+s dir

SSH and Port Forwarding

(I) SSH with X. To simply get X over SSH, do
ssh -X name@machine xterm

(II) No X?   If you installed fedora with minimal package set, you may see:
$ ssh -YC remotebox                                    
[major@remotebox ~]$ xterm                              
xterm: Xt error: Can't open display:                    
xterm: DISPLAY is not set          
                                                       
source
(III) Simple Port Forwarding

Here we forward port 1143 on localhost to 143 (IMAP) on imap.example.com.
    ssh -f -N -q -L 1143:localhost:143 username@imap.example.com
  • -f tells ssh to go into the background (daemonize).
  • -N tells ssh that you don't want to run a remote command. That is, you only want to forward ports.
  • -q tells ssh to be quiet
  • -L specifies the port forwarding
Source: Main, Also

How long did that command take to run?

SIMPLE ANSWER
Simply use the command time to see how long it took to execute

$> time cp -R sourcefolder targetfolder          
real 0m21.093s                                  
user 0m0.008s                                    
sys 0m0.717s                                    
 


real - is the full time it took to run the command (how long you waited).
user - is the CPU time used by the program itself.
sys - is the CPU time used by the system calls

Perhaps also see GNU time as an alternative?

Source

POWER ANSWER
Measure time of program execution and store that inside a variable
usr@srv $ mytime="$(time ( ls ) 2>&1 1>/dev/null )"
usr@srv $ echo "$mytime"

real    0m0.006s
user    0m0.001s
sys     0m0.005s
Perhaps even just use date command, and measure differences from start to finish.

START=$(date +%s.%N)
command
END=$(date +%s.%N)
DIFF=$(echo "$END - $START" | bc)
# echo $DIFF
Source: unix.stackexchange.com

RCS - Simple Version Control

RCS is a great simple version control. No need to create repositories. Just use it in place!  Create the file, then just check it in (creates initial archived version-controlled file: filename,v). Then just check it out again to do editing.

Check in:      $ ci -u inetd.conf
Check out:    $ co -l services

Common RCS operations:
RCS operationCommand line
Initial check-in of file (leaving file active in filesystem)ci -u filename
Check out with lockco -l filename
Check in and unlock (leaving file active in filesystem)ci -u filename
Display version x.y of a fileco -px.y filename
Undo to version x.y (overwrites file active in filesystem with the specified revision)co -rx.y filename
Diff file active in filesystem and last revisionrcsdiff filename
Diff versions x.y and x.zrcsdiff -rx.y -rx.zfilename
View log of check-insrlog filename
Break an RCS lock held by another person on a filercs -u filename

Source: O'Reilly: The Five-Minute RCS Tutorial - Automating System Administration with Perl
also see: http://www.yolinux.com/TUTORIALS/LinuxTutorialRCSintro.html

BTW: think co -l  as being "locked" from use by other programmers (one edit at a time). It may not be necessary to use -u to unlock the file.