the fact of real shit

SSL implementation for Django project in custom port

Here I’m going to implement SSL in Django project which will access through custom port. To do this I’m going to use Apache, for SSL I’m going to use letsencrypt and my Django project containerize in docker. I’m going to bring content through Apache proxy technique.

First of all we need to execute (any) Django project. Please follow Create Docker Container for Hello World with Django and uWsgi Server to create a simple Hello World Django project. We are going to uwsgi socket instead of http server. So, in Dockerfile last line need to change as follows –

ENTRYPOINT ["uwsgi", "--socket", ":9000", "--workers", "4", "--master", "--enable-threads", "--module", "helloworlddjango.wsgi"]

Now we have our project up and running. Now in Apache create entry for our domain and using certbot of letsencrypt install SSL. Please point document root in any safe location, we will use that document root to install SSL and then we will point our uWsgi server to bring content from our project. There has a lot of resource in internet to achieve this. Please configure such way that domain will redirect non-ssl to ssl url automatically.

After successfully access of domain securely we can move to change SSL port. To do this we need to change listen of Apache configuration. In my server I need to change /etc/apache2/ports.conf (it may vary server to server). Following commands need to use to access custom port –

<IfModule ssl_module>
	Listen 443
	Listen 59222
</IfModule>

Now we need to install “libapache2-mod-proxy-uwsgi” module to access content through Apache proxy technique.

sudo apt-get install libapache2-mod-proxy-uwsgi

We are ready to access our Django project content. We need to append following configuration into our domain configuration of Apache server. In my case file location is /etc/apache2/sites-enabled/helpabodessltest.shahadathossain.com-le-ssl.conf

SSLProxyEngine on
SSLProxyVerify none 
SSLProxyCheckPeerCN off
SSLProxyCheckPeerName off
SSLProxyCheckPeerExpire off

ProxyRequests Off
ProxyPreserveHost On
ProxyPass / uwsgi://127.0.0.1:9000/ keepalive=On
ProxyPassReverse / uwsgi://127.0.0.1:9000/

Please note, we need to put these code inside “VirtualHost” block. Also need to change “VirtualHost” tag like as follows –

<VirtualHost *:59222>

Also we can put redirect code in Apache from http to https with custom port like following code. Note that we need to put this code into general (80) configuration of the domain (also inside VirtualHost block)

RewriteEngine on
RewriteCond %{SERVER_NAME} =helpabodessltest.shahadathossain.com
RewriteRule ^ https://%{SERVER_NAME}:59222%{REQUEST_URI} [END,NE,R=permanent]

That’s all, we need to restart Apache server. If everything goes fine we can visit our domain with custom port to see “Hello World” output in browser. Thanks.

Posted in apache, PythonTagged ,

Create Docker Container for Hello World with Django and uWsgi Server

I was searching a Hello World implementation for Django of Python in Docker container, but can’t find any good resource at online. So, I plan to code it myself and document it.

This is pure Docker implementation, you don’t need to create any project for Django. You just need Dockerfile to see “Hello World” at browser which powered by Django and uWsgi module.

Here is high level explanation that I’m going TODO –

  • Python, Pip and setuptools installation and upgrade
  • Create requirement.txt file
  • Execute requirement.txt file with Pip
  • Create Django project
  • Modify project settings to allow our domain in Django
  • Replace project’s urls.py to send “Hello World” string to output
  • Code to run server through uWsgi module

Entire steps I’ll do into a single Dockerfile, which we need to build and run through Docker. Here is step by step implementation of Dockerfile.

FROM python:3.11.3
WORKDIR /code
RUN pip install --upgrade pip
RUN pip install setuptools
RUN pip install -U setuptools

Its pretty straight forward, we are using Python 3.11.3 and install Pip and setuptools here.

RUN echo "Django==4.2" >> requirements.txt
RUN echo "uWSGI==2.0.25" >> requirements.txt
RUN pip install -r requirements.txt

Here we create requirement.txt file where we instruct to install Django version 4.2 and uWSGI module version 2.0.25 and then we execute the newly created requirements.txt through Pip.

RUN django-admin startproject helloworlddjango
WORKDIR /code/helloworlddjango
RUN echo "ALLOWED_HOSTS = ['127.0.0.1', 'localhost', 'helpabodessltest.shahadathossain.com']" >> helloworlddjango/settings.py

In this stage we created helloworld project with django-admin (we already Django installed) also we append our project’s settings.py to allow our domain. For this we just append “ALLOWED_HOSTS” variable value.

RUN echo "from django.urls import path" > helloworlddjango/urls.py
RUN echo "from django.shortcuts import HttpResponse" >> helloworlddjango/urls.py
RUN echo "def home_page_view_hello_world(request):" >> helloworlddjango/urls.py
RUN echo "    return HttpResponse('Hello World')" >> helloworlddjango/urls.py
RUN echo "urlpatterns = [path('', home_page_view_hello_world, name='helloworld'),]" >> helloworlddjango/urls.py

This part actually pure Python code we (re)writing our urls.py file where we actually put “Hello World” string when user visit home page of our project.

RUN adduser --disabled-password --no-create-home django
USER django
ENTRYPOINT ["uwsgi", "--http", ":9000", "--workers", "4", "--master", "--enable-threads", "--module", "helloworlddjango.wsgi"]

This is another part where we run our project through uwsgi module. We can run straightly by Django’s builtin server by “manage.py” but here I covered to run uwsgi server.

Here is link https://github.com/razonklnbd/django-hello-world-with-docker where you found complete Dockerfile

To build docker container you have to have docker in your system. After ensuring docker into system you can use following commands to build and run –

sudo docker build -t django-hello-world-mshk .
sudo docker run --name djangohelloworldmshk -d --network=host django-hello-world-mshk:latest

You need to execute into the location where you put your Dockerfile. Please feel free to change container tag and name. You may like following command of docker to see the log and to delete running container (in case you are debugging something)

sudo docker logs djangohelloworldmshk
sudo docker rm $(sudo docker stop $(sudo docker ps -a -q --filter ancestor=django-hello-world-mshk --format="{{.ID}}"))
sudo docker rmi django-hello-world-mshk

That’s all for today! Thanks.

Posted in linux, Python, webdevelopmentTagged , , , ,

Install secured Proftpd w/o database w/ virtual jailed user

Recently I need to install simple ftp server to provide access. I used Proftpd which is I believe is good (I used in small project). When I starting install, I faced some technical problem and overcome it. So, I think I should write my experience for my personal future reference.

  1. Install proftpd-basic (follow https://mtxserv.com/vps-server/doc/how-to-install-a-ftp-server-with-proftpd-debian-ubuntu or any other good document available by searching internet)
    1.a) Configure to use virtual user
    1.b) Add virtual user using “ftpasswd” command
  2. Configure jail option of proftpd configuration (read – https://portal.hostingcontroller.com/kb/a222/how-to-jail-ftp-users-using-proftpd-server.aspx)
    Remove # (uncomment) in front of below line
    DefaultRoot ~
  3. Configure passive ports
    3.a) At firewall allow 20, 21 and those passive ports (example below)
    ufw allow 49xxx:49999/tcp
    ufw reload
  4. Restart proftpd

-> Test ftp connection

Secure ftp connection with self-signed TLS:

  1. Follow TLS configuration part only from https://www.makeuseof.com/install-proftpd-on-ubuntu/ or any other good document available to configure TLS
  2. Replace “TLSProtocol” settings (follow https://serverfault.com/a/1023382)
    TLSProtocol TLSv1 TLSv1.1 TLSv1.2
  3. Restart proftpd

Now test using FTP client, you may see that host name different than server. As because we used self-signed this type of warning we can ignore.

Posted in linux, ubuntuTagged , , , ,

Apache Python3 Gunicorn

My journey to install Gunicorn to server Python project is not pleasant because of old Ubuntu system where Python version 3.5 installed but default Gunicorn not compatible with this version.

So, as suggested from gunicorn.org I need to install Gunicorn version 3 for Python 3 … The point is, I need to install this Gunicorn 3 at outside of my virtual environment.

First of all we need to change wsgi.py file in Python project in my case – “<project root>/helloworld/wsgi.py”

import os, sys
# add the hellodjango project path into the sys.path
sys.path.append('/home/django-helloworld/helloworld')

# add the virtualenv site-packages path to the sys.path
sys.path.append('/home/django-helloworld/myvenv/lib/python3.5/site-packages')

from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'helloworld.settings')
application = get_wsgi_application()

Above file I added two lines because while executing from gunicorn 3 (which installed outside of virtual environment i.e. into OS) Python can’t find Django or other project related package.

Posted in apache, linux, PythonTagged , , , ,

Execute React JS in ntfs partition

I do development in mounted hard drive which is different than OS partition, also I like to use that mounted drive within different OS like windows and linux simultaneously. Which allow me portability of my code backup in different system.

Challenge is, I have to use such file system for that mounted drive which can accessible in most of the OS like windows, linux or iOS. And in this case NTFS is the best file system which is really portable. Problem for this FS is, it can’t support executable bit of linux which lead to raise many problem in React development. Like if you put any React project into that mounted drive, you can’t execute that code.

To solve this problem I take Docker as a solution. Simply, I create docker image of React project and execute that image. Here is the simple Dockerfile for React project –

FROM node:18
WORKDIR /app
COPY package.json ./
RUN npm install
RUN npm install -g npm@9.7.2
COPY . ./
EXPOSE 3000
CMD ["npm", "start"]

You just need to build this docker image and need to run. You can see docker log for any output for your React project.

Posted in ubuntu, windowsTagged , , , ,

Copy large amount of file to remote server using nohup tar and ssh

This command will copy large amount of file to remote server by compressing and decompressing on the fly. It saves time and bandwidth. It will execute in background, so you can detach current login session.

nohup sh -c “tar -c /any/directory/at/source/server/ | gzip -2 | ssh server-alias ‘cat | tar xz -C /target/directory/of/target/server/'” > /dev/null 2>&1 &

here nohup output sent to /dev/null that means i don’t want any nohup output. you can adjust its behavior.

I use the command for millions of file that occupied more than 500 GB.

Posted in linuxTagged , , ,

add new hard disk into ubuntu more than 2TB size

lsblk

will list available device

parted /dev/sdd

considered device “sdd” from lsblk output

(parted) mklabel gpt
(parted) mkpart primary ext3 0 100%
(parted) print
(parted) quit

mkfs.ext3 /dev/sdd1

this command will format this hard disk into ext3 file system as we instruct by parted command

mkdir /home/data

mounting point directory creating

mount -t ext3 /dev/sdd1 /home/data

mounting formatted hard disk into target directory

blkid

try to find ID of new hard disk to write into fstab so that after restart our hard disk will mount automatically

sample output of blkid

/dev/sdd1: UUID="20e4b16b-4d4c-4053-b6f4-a2c103f2db2f" TYPE="ext3" PARTLABEL="primary" PARTUUID="33658d68-726f-4398-992f-2aaafebe17ff"

vi /etc/fstab

give an entry for our new hard disk at the end of this file

example entry

UUID=20e4b16b-4d4c-4053-b6f4-a2c103f2db2f /home/data ext3 nofail 0 0
Posted in linux, ubuntuTagged , , , ,

recursive change group and file mode in linux and detach active login session

change group

nohup sh -c “find /any/path/that/need/to/change/* -group mygroup -exec chgrp www-data {} \;” > /dev/null 2>&1 &

traditional way

nohup sh -c “chgrp -R www-data /any/path/that/need/to/change” > /dev/null 2>&1 &

change mode

nohup sh -c “find /any/path/that/need/to/change/* -perm u=rw,g=r,o=r -execdir chmod g+w {} \;” > /dev/null 2>&1 &

traditional way

nohup sh -c “chmod -R g+w /any/path/that/need/to/change” > /dev/null 2>&1 &

Posted in linux, ubuntuTagged , , , , , ,

Install php 7.2 ssh2 in ubuntu 16x

recently i need to install ssh2 connection through my php code to connect remote server by sftp for file transfer. i’m using php 7.2 and face a “sigment fault” issue for normal installation. i solved this issue by install required demon. hope it may help someone who face same issue.

first you need to install/upgrade some basic program

apt-get install gcc make autoconf libc-dev pkg-config

then install base library

apt-get install libssh2-1-dev

now install required php modules

apt-get install php7.2-dev php-pear

now install ssh by pecl (the most important part of installation)

— pecl channel-update pecl.php.net
pear config-show
— pear config-set php_ini /etc/php/7.2/apache2/php.ini
— pear config-set temp_dir /etc/php/temp/pear
pecl install ssh2-1.1.2

ignore commented line OR use if you understand by yourself

now you need to enable ssh2 extension into your php cli installation

echo “extension=ssh2.so” > /etc/php/7.2/mods-available/ssh2.ini
ln -s /etc/php/7.2/mods-available/ssh2.ini /etc/php/7.2/cli/conf.d/30-ssh2.ini

please check you php installation/configuration path. set priority on your own. i set here 30 without proper understanding 😀

now another important part is your PHP code. when we use ssh2 in fopen wraper, in other version of ssh2 connection we need to open a connection and we can use resource id. but with the above change you must use user, password, port i.e. full access information every time we need to connect to server. here is my sample code –

$fh = @fopen(‘ssh2.sftp://’ . $this->user.’:’.$this->pass.’@’.$this->ip.’:’.(intval($this->port)>0?intval($this->port):22) . $pRemoteLocation, $pMode);

all other code like directory creation or any other command execution may be same as before.

Posted in php, ubuntuTagged , , , , , , ,

Be organized: File Name Convention and Digital Storage Organizing Tips

When I’m at class IX, that time I take a crash course for good hand writing. But today I do most of my job at my PC where no hand writing is needed? Is it a wasted of time that everyone value?

Do you do a lot of work with documents that constantly have to be saved? Well, if you do, you should know that the first time you save a file, you should choose a “file name” for it to be stored under. Note that some programs will automatically put a file name in for you, but it is much better if you name your own files. That way, you have a better chance of finding them later on.

The first time you save your work, you should use the Save As command to tell your computer what “file name” you want to save your work in. (In some programs, if you use the Save command, the first time you save, it will act as if you clicked on the Save As command anyway, but this is only in some programs. So, all in all, you should develop a habit of using the Save As command the first time you save a new file). The Save As and Save commands are usually under the File menu as well.

So, when you are typing a new document in your word processing program, the first time you go to save it, click on File to bring the menu down and then click on Save As to bring its dialogue box up. In the Save As dialogue box, you can tell your computer where to put your file and what to call it. I won’t get into where to put your file here, except to say that if the computer is putting your files in the My Documents folder, that is fine for now. You can always go and change it later.

Another point is for file extension is; many OS hide the file extension for normal user. It’s a good practice to show extension all the time so that you know by which program is best suit for open that file by analyzing extension.

Next, you have to tell your computer what “file name” to save your file under. You should name your file according to what is in it. For example, if it is a letter to your son, John, call it “Letter to John.” Don’t just name it “Letter.” That is too vague.

Here are some examples of good file names:

2009 Taxes for Bob Smith
Personal Budget 2008
Car Prices 2009
Investment Notes from June 2007 Course
Daily Weight for John Starting March 2008
To Do List

Please note: Careful about to do not use periods, especially at the end of your file names.

Here are some examples of bad file names (the problem is listed beside each one):

John This does not say what is in the file (if this is a letter, calculations, genealogy information, etc).
Letter This does not say who it is for.
Letter to John. This has a period at the end of it, which causes problems.
To Do List March 20/09 This file name has a slash ( / ) between the 20 and the 09. The computer will not accept this.
Letter to “Mom” The quotes around Mom will not be accepted by the computer.
Interest * Principal – List of Payments This file has an asterisk ( * ) in it, which the computer will not accept. The dash ( – ) is okay.

So, rather than memorizing all the details and risk having a problem, keep it simple. When you name a file, use only letters and/or numbers, with no punctuation marks. This will make everything easier on you and on your computer!

When create a file that is personal; Start them with your initials (i.e PR: Pronay Rozario) also do the same for important Personal file folders. It’s extremely easy to find your personal and important files by searching for your initials. One more thing…if you create any general use folders, you know the name initials of that folder. If you want to delete it, it’s easy!

When I’m thinking to find files from my colleague’s computer I’m very much scared that I can find it. A well organized file system may work easy for all to find important file from other’s computer. This is not only important for one who uses that computer but also for one who want to help him when he is out of office or at leave. And for common PC this is extremely important, isn’t it?

You need to remember following point to organize your folders –

  • Other users need to find the entire required file quickly.
  • You want to search your required file from archive.
  • You may guess file location for particular working file and find it to that location.
  • You may backup your data for safety purpose.

For above reason you may want your entire file into a common place that is easy to backup and find. Also it’s easy to other to find to that location.

For a well organized file system you may divide your entire file system into category. The basic category I can suggest – Work, Personal, Important Collection, Entertainment, Archive or Past Work, Others etc. I’m always kept a folder named others. In this folder I like to put those file which has no head or name or category, temporary file that might need to save for a limited times. I like to use drive for each root category. If you have not enough drive into your system or you use flat system like Linux or Unix you can create folder into root directory or to that drive you use for store data. I don’t like to use system directory for store data.

Here are some tips to organize your computers files and folders:

  1. One place for all: For many reasons, it’s smart to take advantage of the Documents feature (called My Documents in Windows XP and earlier versions) in Microsoft Windows but I don’t rely on this because it placed into system directory or system drive.  But it’s important to keep the entire document into a central place to take following advantage –
    1. Find files. It’s easy for indexing by OS to provide search result if you keep your file in one place.
    2. Back up files. You should back up files regularly—and keeping all your files in one place helps make backup a snap into backup media like CD, DVD or Magnetic Tape.
    3. Keep files separate from programs. By separating document files and program files you reduce the risk of accidentally deleting your documents when you install or upgrade programs.
  2. Adopt consistent methods for file and folder naming: Every company has their own naming convention. If your company haven’t one develop a naming scheme for the kinds of files you create most often and then stick to it. Do not use spaces in file names, keep file names under 27 characters, and use all lower case. So a file named should be “square_pharma” rather than “Square Pharmaceuticals Limited”. Oracle developer may be wanted to put all UPPER CASE and java programmer may want to do it with Camel Case. But I recommend you that, if you break any of these rules, be consistent about it.
  3. Keep names short: Even though Windows allows you to use long file names, it does not necessarily mean you should. Long file names are harder to read.
    1. Use abbreviations. Keep file names short by using common abbreviations, such as “MTNG” for meeting or “ACCNTNG” for accounting. This makes the file names more descriptive and you can more easily find files through Search if it’s necessary. I like to trim all vowels except first one for abbreviations. If possible create your own abbreviations style. But you must keep log and explanation written into a text file into root directory. Named that text file – “abbreviations.txt” or “readme.txt”. Please note, if you consistent with one rule you don’t need to put the text file.
    2. Let your folder structure do some of the naming: For example, rather than create a file called “great_bangladeshi_novel_chapter_one_first_effort.doc”, you can build a structure like:

      creative_writtings >> great_bangladeshi_novel >> draft01_u20091110_dr3 >> ch1 >> <then your file name>.doc
      creative_writtings/great_bangladeshi_novel/draft01_u20091110_dr3/ch1
  4. Nest folders within folders: Create other folders within these main folders as need arises. For instance, a folder called “invoices” might contain folders called “2004”, “2005” and “2006”. A folder named for a client might include the folders “customer_data” and “correspondence”. The goal is to have every file in a folder rather than having a bunch of orphan files listed.
  5. Organize files by dates: Use a date in the document name. Such as dv20081215, this would mean December 15, 2008. This puts all the DV sent at that specific date together and sorted by date.
  6. Be specific: Give files logical, specific names and include dates in folder names if possible. The goal when naming folder is to be able to tell what the file is about without having to open it and look. So if the document is a letter to a customer reminding him that payment is overdue, call it something like “overdue20081206” rather than something like “letter”. How will you know who the letter is to without opening it?
  7. Don’t save unnecessary files: Be selective about the files you keep. You probably don’t need to keep them all. With e-mail, for example, you rarely need to keep everything you receive.
  8. Keep individual folder for a project: Keep your entire document related a project into a folder. So, you can take back up for a project and burn CD.
    1. Separate ongoing and completed work. To keep the Documents folder from becoming too unwieldy, use it only for files you’re actively working on. As a result, you can reduce the number of files you need to search through and the amount of data you need to back up. Every month or so, move the files you’re no longer working on to a different folder or location, such as a folder on your desktop, a special Archive folder, flash drive, external hard drive, or even on a CD.
    2. Use common names. To make it easier to search for documents, name your files and folders with easily found names, such as model numbers, project names, or the project lead in the title. Suppose every project should have proposal. So, named this file as “proposal.doc” something like this. Every project need images file so create a folder named “images” into your project folder. So, that every image is related on that project can be stored into that folder.
  9. Use shortcuts and shortcut links instead of multiple copies: If you need to get to the same file from multiple locations, don’t create copies of the file. Create shortcuts to it instead. To create a shortcut, right-click on the file and click Create Shortcut. You can drop and drag the shortcut to other locations. Moreover you may need to organize your folder such way like current working folders, folder of MD sir, folder of software department etc. Those folders may be categorized by different way. So you can create shortcut of those folders and organize several way.
  10. Cull your files regularly: Sometimes what’s old is obvious as in the example of the folder named “Invoices” above. If it’s not, keep your folders uncluttered by clearing out the old files. Do NOT delete business related files unless you are absolutely certain that you will never need the file again. Instead, in your main collection of folders in your data storing drive or root folder, create a folder called “Old” or “Inactive” and move old files into it when you come across them.
  11. Back up your files regularly. Whether you’re copying your files onto another drive or onto tape, it’s important to set up and follow a regular back up regimen.
  12. Put Reference on the desktop: Put a folder named “important_shortcut” on the desktop. Put your entire folders or files shortcut icon into that folder. So, you can save several clicks of the mouse to get where you want to be sooner.

Proposed convention for a well organized file or folder name:

The proposed file naming convention defines a readable, delimited, long filename format. The delimiting character is an underscore or hyphen.  In all cases where an alphabetical character is called for, the character must be lower case. OS may be treat upper and lower case letters the same or not.  The required contents of the filename will be as follows, in order: “File Name,[ Version Information, Create Date with Time, Last Updated Date with Time]” Additional information may be added as required by the user.  The working group suggests that the additional information be in the following order: “Optional 1, Optional 2, and so on”. Additional information will add before optional information. If additional information exists there must be present optional information.  The extension will always follow.

So the template for the file name is as follows –
[File Name]__[Additional Information]__[Optional Information].[Extension]

Here point to be noted that, delimiter is double underscore of each section. So, you can’t use double underscore into a section. You can use single underscore or single hyphen to delimit each word. Double hyphen is reserved for system purpose or automatically generated file name. And we discourage you to use single hyphen too.

File Name & Additional Information:

File Name will discuss later. Additional information is totally determined by user. And we discourage to use additional information because you have full right to make your own style file name.

Optional Information:

Optional information is consisting with “Create Date with Time and Last Updated Date with Time, Version Information”. For put create date you need to put leading ‘c’ and for update date you need to put ‘u’. You can give any one information. And total information is optional. But it good practice to put this information into your file name. But if you put this information you must follow the order and delimit each section with single underscore.

Each version number will followed by ‘v’ and then version number without any delimiter. Example: v1, v35. Please don’t use 01 or 02 just count from 1 and so on. This is also suggested to use ‘dr’ for draft version followed by revise number. You also suggested putting application version information though it’s optional. I suggest to use application version cause, we will easily recognize by file name to what version I need to use to open this file. I faced the problem when I use Adobe Illustrator or Photoshop. Please follow this order to form version information “application version, version/draft number”. Example: av11v5-3, av9v6, dr9 etc. Here version 5.3 represent as 5 hyphen 3. So, you can user hyphen as delimiter.

Using a date in the file name always state the date ‘back to front’. Why? Because then when you look at your folder and sort it by file name, all the files will sort in the order of the dates. It’s a super-easy way of organizing your files by date. Use four digit years, two digit months, two digit days, two digit hour and two digit minute (we will recognized this minute with NN): YYYYMMDDHHNN or YYYYMMDD or YYYYMM or YYYY or YYYYtoYYYY or MMtoMM or mMMdDD or mMMdDDtomMMdDD or hrHHmnNN

Extension:

Most programs automatically add the correct “file extension”—a 3-letter addition to the end of the filename that identifies the type of file to your computer (.doc = MS Word document; .wpd = WordPerfect document). In general, do not alter the file extension. If your program didn’t provide it automatically provide by yourself with your own standard and according your file type, format and by which program you want to open this file.

Example: (Some examples of good file names with their explanation)

y2009_taxes_for_bob_smith__c20100121_u20100202.doc Here you can’t start file name with number so I use ‘y’ and it also including optional information (create date and last date of modify)
personal_budget_2008__v1.doc Here into optional information we put version information.
car_prices_2009.xls No optional information
investment_notes_from_june_2007_course__av2007dr15.doc It is creating by MS office 2007 and it’s a draft file that is revised 15 times till now.
js_daily_weight_200803__u20080401_v35.doc Here we last update this file at April 1 of 2008 and its revised 35 times when update.
to_do_list__av2007v3.doc The list of what to do today.

The conventions comprise the following 18 rules:

  1. The default file name is determined by that file contains.
  2. The name is formed by taking the full expanded name of the unit and replacing the separating dots with hyphens and using lowercase for all letters.
  3. File names must not contain spaces or any special characters such as “& + # \ / : * ? ” ‘ < > | ! .” or non-alphanumeric characters.
  4. Do not start the file name with a number.
  5. When in doubt, keep the file name as short and simple as possible, but meaningful. For example use hist_100a_readings.html not hist100ab*readings
  6. Be sure to include the extension after the filename – for example .htm, .php, .doc, .xls, .pdf, .ppt, .psd, .ai, .jpg
  7. Avoid using four digit extension name of a file format.
  8. Avoid unnecessary repetition and redundancy in file names and file paths. Example: Good – http://www.eg.edu/business/sell/staff/, Redundant – http://www.eg.edu/business/sell/sellstaff/
  9. Use underscores or hyphens to delimit words, not spaces or capital letters.
  10. When including a number in a file name always give it as a two-digit number, i.e. 01-99, unless it is a year or another number with more than two digits.
  11. If using a date in the file name always state the date ‘back to front’, and use four digit years, two digit months, two digit days, two digit hour and two digit minute (we will recognized this minute with NN): YYYYMMDDHHNN or YYYYMMDD or YYYYMM or YYYY or YYYYtoYYYY or MMtoMM or mMMdDD or hrHHmnNN
  12. When including a personal name in a file name give the family name first followed by the initials i.e PR: Pronay Rozario
  13. Avoid using common words such as ‘draft’ or ‘letter’ at the start of file names, unless doing so will make it easier to retrieve the record.
  14. Order the elements in a file name in the most appropriate way to retrieve the record.
  15. The file names of records relating to recurring events should include the date and a description of the event, except where the inclusion of any of either of these elements would be incompatible with rule 8.
  16. The file names of correspondence should include the name of the correspondent, an indication of the subject, the date of the correspondence and whether it is incoming or outgoing correspondence, except where the inclusion of any of these elements would be incompatible with rule 8.
  17. The file name of an email attachment should include the name of the correspondent, an indication of the subject, the date of the correspondence, ‘attach’, and an indication of the number of attachments sent with the covering email, except where the inclusion of any of these elements would be incompatible with rule 8.
  18. The version number of a record should be indicated in its file name by the inclusion of ‘v’ followed by the version number and, where applicable, draft use ‘d’ followed by the version number. Also use application version (av) with their number by which the file created, except where the inclusion of any of these elements would be incompatible with rule 8.

Finally…

Everyone should have their own policy. But you must think about how can your public accessible file is more accessible in easy way, isn’t it?

For your information, I forgot my good hand writings. Really I missed those style…

Disclaimer:

This article is written for established a common concept for a well organized file structure. Many many thanks to Rahinur Rahman Reza of Square InformatiX Ltd. for his valuable comment on this article that easy for me to write it.

by-

| Md. Shahadat Hossain Khan
|
Web Developer, Square InformatiX Ltd.

Posted in StandardTagged , , , , , , , , , , , , , , , , , ,