Monthly Archives: September 2011


List the contents of a tar or tar.gz file

List the contents of a tar file

<code>tar -tvf file.tar</code>

List the contents of a tar.gz file

<code>tar -ztvf file.tar.gz</code>

List the contents of a tar.bz2 file

<code>tar -jtvf file.tar.bz2</code>

Options:
-t
List the contents of an archive
-v
Verbose mode
-z
Use gzip so that you can process a compressed (.gz) tar file
-j
Use bzip2, use to decompress .bz2 files
-f
filename Use archive file called filename


Linux: Check if a User or a Group Exists 2

You can find out if user exists by searching in the /etc/passwd file using the following command:

egrep -i "^useraccount:" /etc/passwd

The above command will print the matching record from /etc/passwd if the user exists or nothing if the user does not exist.
The ^ symbol is used to make sure there is no characters before the username and the : character is used as the delimiter in the file (which indicates the end of the username). By wrapping the username with these characters we are sure that if we matched a record, we matched the correct record with the full username.

A very simple way to use this code in a script is by utilizing the $? (question mark) variable. The question mark variable contains the exit status of the last command that executed. Specifically, egrep will return 0 if there was a match or else it will return a a positive number (usually 1).
Taking advantage of this behavior, after executing the above command, we check the $? variable to see the result with an if statement.

egrep -i "^useraccount:" /etc/passwd;
if [ $? -eq 0 ]; then
   echo "User Exists"
else
   echo "User does not exist -- Invalid Username"
fi

You can also find out if a group exists by searching in the /etc/group file. Similar to the approach we showed before, we can check if a group exists using the following:

egrep -i "^groupname" /etc/group;
if [ $? -eq 0 ]; then
   echo "Group Exists"
else
   echo "Group does not exist -- Invalid Group name"
fi

gpasswd

gpasswd group
gpasswd -a useraccount groupname
gpasswd -d useraccount groupname
gpasswd -R groupname
gpasswd -r groupname
gpasswd [-A useraccount,...] [-M useraccount ,...] groupname

gpasswd is used to administer the /etc/group file (and /etc/gshadow file if compiled with SHADOWGRP defined).
System administrator can use:
-A option to define group administrator(s)
-M option to define members and has all rights of group administrators and members.

Group administrator can use:
-a to add users
-d to delete users.

Administrators can use:
-r option to remove group password. When no password is set only group members can use newgrp to join the group.
-R disables access to the group through newgrp command.

gpasswd called by a group administrator with group name only prompts for the group password. If password is set the members can still newgrp without a password, non-members must supply the password.


Photo ClubΦωτογραφικός Όμιλος

The Photo Club of the University of Cyprus was established in 1993.

 

Our aim is the development of photography and we try to achieve this by the means of courses, lectures, workshops, photography exhibitions, trips and screenings to the University. In some cases we might process black and white film in the darkroom of the University. Anyone can become a Club member as long as they are students at the University of Cyprus and provided that they love photography even though they have not taken the first difficult steps in the photographic art:).

 

Our meetings happen regularly once a week (day and time of the changes every semester) where we implement short talks or lectures (~ 1 hour).

 

email:[email protected]

site:http://photoclub.bytefreaks.netΟ Φωτογραφικός Όμιλος του Πανεπιστημίου Κύπρου ιδρύθηκε το 1993.

 

Στόχος μας είναι η ανάπτυξη της φωτογραφίας και προσπαθούμε να το πετύχουμε δια μέσω μαθημάτων, διαλέξεων, εργαστηρίων, εκθέσεων φωτογραφίας, εκδρομών και προβολών στο Πανεπιστήμιο Κύπρου. Ακόμη, σε κάποιες περιπτώσεις θα μπορούσαμε επεξεργαστούμε ασπρόμαυρο φιλμ στον σκοτεινό θάλαμο του Πανεπιστημίου. Οποιοσδήποτε μπορεί να γίνει μέλος του ομίλου, εφόσον είναι φοιτητές στο Πανεπιστήμιο Κύπρου και υπό τον όρο ότι αγαπά τη φωτογραφία, ακόμη κι αν δεν έχει κάνει τα πρώτα δύσκολα βήματα στη φωτογραφική τέχνη:).

 

Συνεδριάσεις μας γίνοντε τακτικά μία φορά την εβδομάδα (μέρα και ώρα αλλάζει κάθε εξάμηνο) όπου κάνουμε σύντομες ομιλίες ή διαλέξεις (~ 1 ώρα).

 

email: [email protected]

τοποθεσία: http://photoclub.bytefreaks.net