In computing, tar (derived from tape archive) is both a file format (in the form of a type of archive bitstream) and the name of a program used to handle such files.
I would describe tar as a zip file. It packages everything in one file. For example if I have my html page in one folder I can tar the folder in one file and then untar it somewhere else.
To create an archive of a directory and its contents you would type the following and press enter:
$ tar -cvf name.tar /path/to/directory
and to untar
$ tar -xvf name.tar
This page is a random collection of notes addressed to myself. Nothing here is intended as a guide per say, however i have posted them hoping that it may help someone. Blog about Linux and unix related stuff. Everything in this blog can be copied or edited GNU General Public License (version 2 or newer) http://www.gnu.org/licenses/gpl.html
keskiviikko 15. toukokuuta 2013
Github
GitHub is a web-based hosting service for software development projects that use the Git revision control system.
$ git remote add origin git@github.com:yourname/projectname.git
I am still trying to get GitHub working with my Linux.
Install git:
$ sudo apt-get install git
go to project folder
$ git init
$ git add .
$ git commit
Then create Github account https://github.com/
Generate SSH Keys and add to your account
Then it should be this easy but I can't figure out what is wrong
$ git push -u origin master
I get error repository not found. Blah. Help me ?
After that I tried with these:
$ git remote add origin ssh://tero@example.com/home/tero/thello.git
After that I tried with these:
$ git remote add origin ssh://tero@example.com/home/tero/thello.git
$ git push origin master
$ git branch --set-upstream master origin/master
Final task, my own module. Puppet - Tomcat module
Our final task was to create our own module for puppet. I decided to do something which is useful for myself. Because we did a school project with tomcat I wanted to install tomcat with my module. First we download the tomcat tar file, then extract it, remove the tar, change configuration file from template and finally start the service.
I am using virtualbox on 64bit windows 7 with 12GB ram + AMD 1055t 6 core processor. Linux used for testing, Xubuntu 12.10
exec {'start service':
command => "sh startup.sh",
cwd => "/home/shnigi/apache-tomcat-7.0.40/bin/",
path => '/bin/',
require => File['/home/shnigi/apache-tomcat-7.0.40/conf/tomcat-users.xml']
}
}
$ puppet apply --modulepath modules/ -e 'class {"tomcat":}'
The problem is that the startup.sh needs probably sudo command and I don't know how to bypass that. Everything else is working correctly, because if I run the startup manually tomcat manager gui shows correctly.
$ cd /home/shnigi/apache-tomcat-7.0.40/conf
$ sudo sh startup.sh
I am using virtualbox on 64bit windows 7 with 12GB ram + AMD 1055t 6 core processor. Linux used for testing, Xubuntu 12.10
I did the work in small pieces. First I created puppet test module which placed simple txt file in temp folder. After that I did downloading, then extracting, removing, template and startup.
Tomcat obviously need Java. So I started by creating openjdk module. As you can see from my modules tree, there are three modules. One for testing, one for java and one for tomcat.
ensure => installed,
}
}
class tomcat(
$source = 'http://mirrors.axint.net/apache/tomcat/tomcat-7/v7.0.40/bin/apache-tomcat-7.0.40.tar.gz',
$package = 'apache-tomcat-7.0.40.tar.gz',
)
{
exec { 'download-apache-tomcat-7.0.40.tar.gz':
command => "wget $source",
cwd => "/home/$id",
path => '/usr/bin/',
}
exec {'extract-apache-tomcat-7.0.40.tar.gz':
command => "tar -xvf $package",
cwd => "/home/$id",
path => '/bin/',
require => Exec['download-apache-tomcat-7.0.40.tar.gz'],
}
exec {'remove package':
command => "rm $package",
cwd => "/home/$id",
path => '/bin/',
require => Exec['extract-apache-tomcat-7.0.40.tar.gz']
}
## TODO change variable for shnigi
file {'/home/shnigi/apache-tomcat-7.0.40/conf/tomcat-users.xml':
ensure => file,
content => template ('tomcat/tomcat-users.erb'),
require => Exec['extract-apache-tomcat-7.0.40.tar.gz'],
}
Tomcat obviously need Java. So I started by creating openjdk module. As you can see from my modules tree, there are three modules. One for testing, one for java and one for tomcat.
The java module is very simple. Its only task is to install java developement kit. The code goes like this:
class java {
package { 'openjdk-7-jdk':ensure => installed,
}
}
And to run it:
$ sudo puppet apply --modulepath modules/ -e 'class {"java":}'
Now we have jdk installed and tomcat is ready to be deployed. Of course I had to download tomcat beforehand to get the template file from conf folder which has the tomcat-users.xml file. My tomcat init.pp goes like this:
class tomcat(
$source = 'http://mirrors.axint.net/apache/tomcat/tomcat-7/v7.0.40/bin/apache-tomcat-7.0.40.tar.gz',
$package = 'apache-tomcat-7.0.40.tar.gz',
)
{
exec { 'download-apache-tomcat-7.0.40.tar.gz':
command => "wget $source",
cwd => "/home/$id",
path => '/usr/bin/',
}
exec {'extract-apache-tomcat-7.0.40.tar.gz':
command => "tar -xvf $package",
cwd => "/home/$id",
path => '/bin/',
require => Exec['download-apache-tomcat-7.0.40.tar.gz'],
}
exec {'remove package':
command => "rm $package",
cwd => "/home/$id",
path => '/bin/',
require => Exec['extract-apache-tomcat-7.0.40.tar.gz']
}
## TODO change variable for shnigi
file {'/home/shnigi/apache-tomcat-7.0.40/conf/tomcat-users.xml':
ensure => file,
content => template ('tomcat/tomcat-users.erb'),
require => Exec['extract-apache-tomcat-7.0.40.tar.gz'],
}
## TODO fix startup
exec {'start service':
command => "sh startup.sh",
cwd => "/home/shnigi/apache-tomcat-7.0.40/bin/",
path => '/bin/',
require => File['/home/shnigi/apache-tomcat-7.0.40/conf/tomcat-users.xml']
}
}
$ puppet apply --modulepath modules/ -e 'class {"tomcat":}'
The problem is that the startup.sh needs probably sudo command and I don't know how to bypass that. Everything else is working correctly, because if I run the startup manually tomcat manager gui shows correctly.
$ cd /home/shnigi/apache-tomcat-7.0.40/conf
$ sudo sh startup.sh
Now surf to http://localhost:8080 and see the tomcat manager-gui =)
Sources:
Puppet mumble server module
I wanted to create TeamSpeak 3 module for my raspberryPi but teamspeak is not supported on ARM so I chose to create mumble server instead. It seems that the mumble-server configuration file doesn't accept my edits so this should basically work, but I was too lazy to figure it out why for example the welcome message didn't change.
Inside puppet folder:
Under my modules folder I created "mumble" folder and inside manifests there is the init.pp file. Inside init.pp:
class mumble {
package { 'mumble':
ensure => installed,
}
}
/Desktop/puppet$ sudo puppet apply --modulepath modules/ -e 'class {"mumble":}'
And it worked.
Inside my mumble folder beside manifests I create folder named templates. There I want to copy mumble server configuration file from /etc
$ sudo cp /etc/mumble-server.ini /home/username/Desktop/puppet/modules/mumble/templates
And now back to the init.pp file
class mumble {
package { 'mumble-server':
ensure => installed,
before => File ['/etc/mumble-server.ini'],
}
package { 'mumble':
ensure => installed,
}
file { 'mumble-server.ini':
path => '/etc/mumble-server.ini',
ensure => present,
content => template('mumble/mumble-server.ini.erb'),
require => Package ['mumble-server'],
}
service { mumble-server:
require => Package ['mumble-server'],
ensure => running,
notify => Service["mumble-server"],
}
}
$ sudo puppet apply --modulepath modules/ -e 'class {"mumble":}'
And it worked.
Inside puppet folder:
Under my modules folder I created "mumble" folder and inside manifests there is the init.pp file. Inside init.pp:
class mumble {
package { 'mumble':
ensure => installed,
}
}
/Desktop/puppet$ sudo puppet apply --modulepath modules/ -e 'class {"mumble":}'
And it worked.
Inside my mumble folder beside manifests I create folder named templates. There I want to copy mumble server configuration file from /etc
$ sudo cp /etc/mumble-server.ini /home/username/Desktop/puppet/modules/mumble/templates
And now back to the init.pp file
class mumble {
package { 'mumble-server':
ensure => installed,
before => File ['/etc/mumble-server.ini'],
}
package { 'mumble':
ensure => installed,
}
file { 'mumble-server.ini':
path => '/etc/mumble-server.ini',
ensure => present,
content => template('mumble/mumble-server.ini.erb'),
require => Package ['mumble-server'],
}
service { mumble-server:
require => Package ['mumble-server'],
ensure => running,
notify => Service["mumble-server"],
}
}
$ sudo puppet apply --modulepath modules/ -e 'class {"mumble":}'
And it worked.
perjantai 10. toukokuuta 2013
Linux hosts
This is something that we went through very fast on last class and I don't remember everything. Anyway under /etc there is a file named "hosts" I found my computers IP address there with my computers name. I added a line with same IP and www name like this
127.0.0.1 www.test.fi
Then I installed apache2 and pointed my browser to www.test.fi and the web page showed !
127.0.0.1 www.test.fi
Then I installed apache2 and pointed my browser to www.test.fi and the web page showed !
Refreshing memory, testing puppet
It's been a long time since a used puppet and I wanted to refresh my memory a little bit. I created a simple puppet code that creates a file in tmp folder to see if puppet is working correctly.
Start always by updating repositories
$ sudo apt-get update
$ sudo apt-get -y install puppet
Preparations. I created puppet folder hierarchy on my desktop.
$ pwd
/home/username/Desktop
$ mkdir puppet
$ cd puppet
$ mkdir modules
$ cd modules
and here we can create our modules. Because this will be a test file I create a folder named test.
$ mkdir test
$ cd test
$ mkdir manifests
$ cd manifests
$ nano init.pp
class test {
file { '/tmp/test':
ensure => file,
mode => 777,
content => "foo is so bar",
}
}
cd to puppet folder and then apply.
$ puppet apply --modulepath modules/ -e 'class {"test":}'
$ warning: Could not retrieve fact fqdn
notice: /Stage[main]/Test/File[/tmp/test]/ensure: defined content as '{md5}082ba698ca7aa38660ca953b78f87b40'
notice: Finished catalog run in 0.09 seconds
And now if you check tmp folder there is a new file.
Start always by updating repositories
$ sudo apt-get update
$ sudo apt-get -y install puppet
Preparations. I created puppet folder hierarchy on my desktop.
$ pwd
/home/username/Desktop
$ mkdir puppet
$ cd puppet
$ mkdir modules
$ cd modules
and here we can create our modules. Because this will be a test file I create a folder named test.
$ mkdir test
$ cd test
$ mkdir manifests
$ cd manifests
$ nano init.pp
class test {
file { '/tmp/test':
ensure => file,
mode => 777,
content => "foo is so bar",
}
}
cd to puppet folder and then apply.
$ puppet apply --modulepath modules/ -e 'class {"test":}'
$ warning: Could not retrieve fact fqdn
notice: /Stage[main]/Test/File[/tmp/test]/ensure: defined content as '{md5}082ba698ca7aa38660ca953b78f87b40'
notice: Finished catalog run in 0.09 seconds
And now if you check tmp folder there is a new file.
torstai 2. toukokuuta 2013
Good site to learn or refresh memory - SQL Zoo
http://sqlzoo.net/
Sql zoo has real sql server and there you can train your sql skills or just refresh memory with only web browser, nothing else needed.
Sql zoo has real sql server and there you can train your sql skills or just refresh memory with only web browser, nothing else needed.
keskiviikko 1. toukokuuta 2013
Curl
$ sudo apt-get install -y curl
$ curl localhost
$ ifconfig
$ curl 172.28.9.154
Curl can print websites to terminal for example.
http://en.wikipedia.org/wiki/CURL
$ curl localhost
$ ifconfig
$ curl 172.28.9.154
Curl can print websites to terminal for example.
http://en.wikipedia.org/wiki/CURL
Puppet modulepath command
Inside puppet folder create modules folder and inside modules folder goes all the modules, like apache2 folder, sshd folder etc...
Then run this command for example from
xubuntu@xubuntu:~/Desktop/puppet$
puppet apply --modulepath modules/ -e 'class {"apache2":}'
Then run this command for example from
xubuntu@xubuntu:~/Desktop/puppet$
puppet apply --modulepath modules/ -e 'class {"apache2":}'
Tilaa:
Blogitekstit (Atom)