{"id":11,"date":"2006-12-19T11:33:00","date_gmt":"2006-12-19T09:33:00","guid":{"rendered":"http:\/\/blog.sqawasmi.com\/?p=11"},"modified":"2008-05-02T03:21:16","modified_gmt":"2008-05-02T01:21:16","slug":"bash-loging-startup-scripts-and-shell-initialization-files","status":"publish","type":"post","link":"https:\/\/blog.sqawasmi.com\/index.php\/2006\/12\/19\/bash-loging-startup-scripts-and-shell-initialization-files\/","title":{"rendered":"bash loging, startup scripts and shell initialization files"},"content":{"rendered":"<p>bash loging, startup scripts and shell initialization files..<\/p>\n<p>ok, i will talk about bash,<\/p>\n<p>When a user logs in, environment variables are set from various places.<br \/>\nstartup scripts in order is like this:<\/p>\n<ol>\n<li>\/etc\/passwd<\/li>\n<li>\/etc\/shadow<\/li>\n<li>\/etc\/group<\/li>\n<li>\/etc\/profile will run.<\/li>\n<li>then all the files (that end with sh) in the \/etc\/profile.d directory<\/li>\n<li>then bash will look for ~\/.bash_profile, ~\/.bash_login, and ~\/.profile, in that order, and reads and executes commands from the first one that exists and is readable. (i.e if ~\/.bash_profile is not exists then bash will look for ~\/.bash_login then ~\/.profile and sources that instead). may be ~\/.bash_profile source ~\/.bash_login and ~\/.bashrc in it.<\/li>\n<\/ol>\n<ul>\n<li>~\/.bashrc might point to \/etc\/bashrc<\/li>\n<\/ul>\n<ul>\n<li>at logout ~\/.bash_logout may run<\/li>\n<\/ul>\n<ul>\n<li>bash command history are kept in ~\/.bash_history<\/li>\n<\/ul>\n<p>some of this scripts may not exists in your system (~\/.bash_profile, ~\/.bash_login, ~\/.profile, ~\/.bashrc, \/etc\/bashrc and and ~\/.bash_logout),<\/p>\n<p>lets we explain them:<br \/>\n<span class=\"fullpost\"><br \/>\n1. \/etc\/passwd<br \/>\n<\/span><span class=\"fullpost\">\/etc\/passwd file contains basic user attributes. This is an ASCII file that contains an entry for each user. Each entry defines the basic attributes applied to a user.<br \/>\nAn entry in the \/etc\/passwd file has the following form (one entry per line):<br \/>\nName:Password:UserID:PrincipleGroup:Gecos:HomeDirectory:Shell<br \/>\nFor security reasons, most Linux Distributions no longer store password in this file (store it in \/etc\/shadow).<br \/>\nA corrupt \/etc\/passwd file can easily render a Linux box unusable.<br \/>\nfor more info about \/etc\/passwd see:<br \/>\nmanpages: man passwd<\/span><\/p>\n<p>2. \/etc\/shadow<br \/>\nshadow contains the encrypted password information for user&#8217;s accounts and optional the password aging information (other information such as account or password expiration values, etc).<br \/>\nfor more info:<br \/>\nmanpages: man shadow<br \/>\n<span style=\"font-size:85%;\"><a href=\"http:\/\/db.assam-glug.org\/documentations\/Linux-admin-made-easy\/shadow-file-formats.html\"><span class=\"fullpost\">http:\/\/db.assam-glug.org\/documentations\/Linux-admin-made-easy\/shadow-file-formats.html<\/span><\/a><\/span><br \/>\n<span class=\"fullpost\"><br \/>\n3. \/etc\/group<br \/>\n\/etc\/group is an ASCII file which defines the groups to which users belong. There is one entry per line, and each line has the format:<br \/>\ngroup_name:passwd:GID:user1,user2,user3&#8230;.userN<br \/>\nas you see, you have to sperate each user with comma.<br \/>\nfor more info see:<br \/>\nmanpages: man group<\/span><\/p>\n<p>4. \/etc\/profile<br \/>\n\/etc\/profile file contains system wide environment stuff and startup programs, all settings that you want to apply to all your users environments should be in this file.<\/p>\n<p>5. \/etc\/profile.d\/*.sh<br \/>\n\/etc\/profile.d is a good place to put application specific settings and their environment variables.<\/p>\n<p>6. ~\/.bash_profile, ~\/.bash_login, and ~\/.profile<br \/>\nthey can be used like \/etc\/profile file but for a specific user&#8230; they are user-specific bash environmental default settings, contains extra configuration options or change default settings.<br \/>\nbash will look for ~\/.bash_profile, ~\/.bash_login, and ~\/.profile, in that order, and reads and executes commands from the first one that exists and is readable.<br \/>\n~\/.profile is good when use another shell (like csh) that will not understand bash command and will look for this file.<\/p>\n<p>* ~\/.bashrc<br \/>\nthis file used for user-specific aliases, export and user functions.<br \/>\n~\/.bashrc might point to \/etc\/bashrc to run global things.<\/p>\n<p>finaly may be you would like to know that when you create a new user, then the home directory for that user will initialised with files from the \/etc\/skel directory (i.e \/etc\/skel directory contains subdirectories and files used to populate a new user&#8217;s home directory). The system administrator can create files in \/etc\/skel\/ directory that will provide a default environment for users.<br \/>\ni dont know a good site talking about that, but take a look at this one:<br \/>\n<span style=\"font-size:85%;\"><a href=\"http:\/\/www.faqs.org\/docs\/linux_admin\/x2331.html\">http:\/\/www.faqs.org\/docs\/linux_admin\/x2331.html<\/a><\/span><\/p>\n<p>to understand them better (\/etc\/profile, ~\/.bash_profile, ~\/.bash_login, ~\/.profile, ~\/.bashrc, \/etc\/bashrc and and ~\/.bash_logout) this sites may give help:<br \/>\n<span style=\"font-size:85%;\"><a href=\"http:\/\/www.faqs.org\/docs\/abs\/HTML\/files.html\">http:\/\/www.faqs.org\/docs\/abs\/HTML\/files.html<\/a><br \/>\n<a href=\"http:\/\/www.faqs.org\/docs\/securing\/chap6sec64.html\">http:\/\/www.faqs.org\/docs\/securing\/chap6sec64.html<\/a><br \/>\n<a href=\"http:\/\/www.faqs.org\/docs\/securing\/chap6sec64.html\">http:\/\/tldp.org\/LDP\/Bash-Beginners-Guide\/html\/sect_03_01.html<\/a><br \/>\n<a href=\"http:\/\/www.linux-migration.org\/ch02s03.html\">http:\/\/www.linux-migration.org\/ch02s03.html<\/a><br \/>\n<a href=\"http:\/\/www.gnu.org\/software\/bash\/manual\/bash.html\">http:\/\/www.gnu.org\/software\/bash\/manual\/bash.html<\/a><br \/>\n<a href=\"http:\/\/www.comptechdoc.org\/os\/linux\/usersguide\/linux_ugenvironment.html\">http:\/\/www.comptechdoc.org\/os\/linux\/usersguide\/linux_ugenvironment.html<\/a><br \/>\n<a href=\"http:\/\/www.linuxfromscratch.org\/blfs\/view\/6.1\/postlfs\/profile.html\">http:\/\/www.linuxfromscratch.org\/blfs\/view\/6.1\/postlfs\/profile.html<\/a><\/span><\/p>\n<h3>Related Images:<\/h3>","protected":false},"excerpt":{"rendered":"<p>bash loging, startup scripts and shell initialization files.. ok, i will talk about bash, When a user logs in, environment variables are set from various places. startup scripts in order is like this: \/etc\/passwd \/etc\/shadow \/etc\/group \/etc\/profile will run. then all the files (that end with sh) in the \/etc\/profile.d directory then bash will look [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"ngg_post_thumbnail":0,"footnotes":""},"categories":[14,7],"tags":[],"class_list":["post-11","post","type-post","status-publish","format-standard","hentry","category-bash","category-scripting-cli"],"_links":{"self":[{"href":"https:\/\/blog.sqawasmi.com\/index.php\/wp-json\/wp\/v2\/posts\/11","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.sqawasmi.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.sqawasmi.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.sqawasmi.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.sqawasmi.com\/index.php\/wp-json\/wp\/v2\/comments?post=11"}],"version-history":[{"count":0,"href":"https:\/\/blog.sqawasmi.com\/index.php\/wp-json\/wp\/v2\/posts\/11\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.sqawasmi.com\/index.php\/wp-json\/wp\/v2\/media?parent=11"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.sqawasmi.com\/index.php\/wp-json\/wp\/v2\/categories?post=11"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.sqawasmi.com\/index.php\/wp-json\/wp\/v2\/tags?post=11"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}